From 53501e27992726d6234afd03641fe19cef554d6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simonas=20=C5=A0erlinskas?= <simonas.serlinskas@nfq.com>
Date: Thu, 24 Jan 2019 14:27:55 +0200
Subject: [PATCH] fix function score test

---
 .../Functional/Query/FunctionScoreQueryTest.php  | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/tests/Functional/Query/FunctionScoreQueryTest.php b/tests/Functional/Query/FunctionScoreQueryTest.php
index fb8c1da..63e8987 100644
--- a/tests/Functional/Query/FunctionScoreQueryTest.php
+++ b/tests/Functional/Query/FunctionScoreQueryTest.php
@@ -35,7 +35,7 @@ class FunctionScoreQueryTest extends AbstractElasticsearchTestCase
                 ],
                 [
                     'title' => 'bar',
-                    'price' => 30,
+                    'price' => 10,
                 ],
             ]
         ];
@@ -61,12 +61,16 @@ class FunctionScoreQueryTest extends AbstractElasticsearchTestCase
     {
         $fquery = new FunctionScoreQuery(new MatchAllQuery());
         $fquery->addScriptScoreFunction(
-            'if (doc[\'price\'].value > ctx._source.target) 
-             { return doc[\'price\'].value * (1 - ctx._source.discount); }
-             return doc[\'price\'].value;',
+            "
+            if (doc['price'].value < params.target) 
+             {
+               return doc['price'].value * params.charge; 
+             }
+             return doc['price'].value;
+             ",
             [
-                'target' => 20,
-                'discount' => 0.9,
+                'target' => 10,
+                'charge' => 0.9,
             ]
         );
 
-- 
GitLab