Skip to content

Commit

Permalink
feat: add boost query parameter to MultipleFieldsFullText criterion
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian ALEXANDRE committed Oct 3, 2024
1 parent a84773e commit 3168030
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 3168030

Please sign in to comment.