diff --git a/src/Query/Compound/FunctionScoreQuery.php b/src/Query/Compound/FunctionScoreQuery.php index 1e9791056894e3c9283cf973c515a9acf45e31ff..0f62f562b4bc37bec745cc30815c1fdde5d5b02e 100644 --- a/src/Query/Compound/FunctionScoreQuery.php +++ b/src/Query/Compound/FunctionScoreQuery.php @@ -91,6 +91,7 @@ class FunctionScoreQuery implements BuilderInterface * @param array $function * @param array $options * @param BuilderInterface $query + * @param int $weight * * @return $this */ @@ -99,14 +100,18 @@ class FunctionScoreQuery implements BuilderInterface $field, array $function, array $options = [], - BuilderInterface $query = null + BuilderInterface $query = null, + $weight = null ) { - $function = [ - $type => array_merge( - [$field => $function], - $options - ), - ]; + $function = array_filter( + [ + $type => array_merge( + [$field => $function], + $options + ), + 'weight' => $weight, + ] + ); $this->applyFilter($function, $query);