Skip to content
Snippets Groups Projects
Commit 093bf045 authored by Luiz Guilherme Fonseca Rosa's avatar Luiz Guilherme Fonseca Rosa Committed by Simonas Šerlinskas
Browse files

Breaking Change: Added "Missing" support to Field Value Factor (#247)

* bump development version number

* missing support

added missing support to [field value factor](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-field-value-factor)

* updated docs

* proposed changes
parent c8a20734
No related branches found
No related tags found
No related merge requests found
......@@ -37,7 +37,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
"dev-master": "5.1-dev"
}
}
}
......@@ -105,7 +105,7 @@ $queryArray = $search->toArray();
```php
$functionScoreQuery = new FunctionScoreQuery(new MatchAllQuery());
$existsQuery = new ExistsQuery('price');
$functionScoreQuery->addFieldValueFactorFunction('price', 0.5, 'ln', $existsQuery);
$functionScoreQuery->addFieldValueFactorFunction('price', 0.5, 'ln', $existsQuery, 0);
$search = new Search();
$search->addQuery($functionScoreQuery);
......
......@@ -50,18 +50,21 @@ class FunctionScoreQuery implements BuilderInterface
* @param float $factor
* @param string $modifier
* @param BuilderInterface $query
*
* @param mixed $missing
* @return $this
*/
public function addFieldValueFactorFunction($field, $factor, $modifier = 'none', BuilderInterface $query = null)
public function addFieldValueFactorFunction($field, $factor, $modifier = 'none', BuilderInterface $query = null, $missing = null)
{
$function = [
$function = array_filter([
'field_value_factor' => [
'field' => $field,
'factor' => $factor,
'modifier' => $modifier,
'missing' => $missing
],
];
], function ($item) {
return $item !== null;
});
$this->applyFilter($function, $query);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment