From 83c47322c09b47c35e3a9db2a8941cdc761b56e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simonas=20=C5=A0erlinskas?=
 <saimaz@users.noreply.github.com>
Date: Thu, 3 May 2018 12:55:27 +0300
Subject: [PATCH] added weight option to the decay function (#262)

---
 src/Query/Compound/FunctionScoreQuery.php | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/Query/Compound/FunctionScoreQuery.php b/src/Query/Compound/FunctionScoreQuery.php
index 1e97910..0f62f56 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);
 
-- 
GitLab