Browse Source

[TEST] Fix GroovyScriptTests failures.

Adrien Grand 10 years ago
parent
commit
56974bf867
1 changed files with 3 additions and 1 deletions
  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");