Преглед на файлове

[TEST] Fix GroovyScriptTests failures.

Adrien Grand преди 10 години
родител
ревизия
56974bf867
променени са 1 файла, в които са добавени 3 реда и са изтрити 1 реда
  1. 3 1
      src/test/java/org/elasticsearch/script/GroovyScriptTests.java

+ 3 - 1
src/test/java/org/elasticsearch/script/GroovyScriptTests.java

@@ -140,8 +140,10 @@ public class GroovyScriptTests extends ElasticsearchIntegrationTest {
         assertSearchHits(resp, "3", "1");
 
         // _score is comparable
+        // NOTE: it is important to use 0.0 instead of 0 instead Groovy will do an integer comparison
+        // and if the score if between 0 and 1 it will be considered equal to 0 due to the cast
         resp = client().prepareSearch("test").setQuery(functionScoreQuery(matchQuery("foo", "dog"))
-            .add(scriptFunction("_score > 0 ? _score : 0", "groovy"))
+            .add(scriptFunction("_score > 0.0 ? _score : 0", "groovy"))
             .boostMode(CombineFunction.REPLACE)).get();
         assertNoFailures(resp);
         assertSearchHits(resp, "3", "1");