Skip to content

Commit

Permalink
Merge pull request #210 from Novactive/feat-MultipleFieldsFullText-cr…
Browse files Browse the repository at this point in the history
…iterion

feat: add boost query parameter to MultipleFieldsFullText criterion
  • Loading branch information
erdnaxelaweb authored Oct 4, 2024
2 parents a84773e + 3168030 commit daa8bfd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ class MultipleFieldsFullText extends Criterion implements CustomFieldInterface
*/
public $boostFunctions = [];

/**
* Array of boost queries.
*
* @var array
*/
public $boostQueries = [];

/**
* @param $value
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,18 @@ public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null)
reset($boostFunction) :
sprintf('sum(%s)', implode(',', $boostFunction));
}
if (!empty($criterion->boostQueries)) {
$queryParams['bq'] = $criterion->boostQueries;
}

$queryParamsString = implode(' ', array_map(function ($key, $value) {
return "{$key}='{$value}'";
if (is_array($value)) {
return implode(' ', array_map(function ($value) use ($key) {
return "{$key}='{$value}'";
}, $value));
} else {
return "{$key}='{$value}'";
}
}, array_keys($queryParams), $queryParams));

return "{!edismax {$queryParamsString}}";
Expand Down

0 comments on commit daa8bfd

Please sign in to comment.