Merge pull request #12328 from alexclare/issue-12327

Fix malformed query generation
This commit is contained in:
Britta Weber 2015-07-22 11:55:41 +02:00
commit 828d8c7754
2 changed files with 8 additions and 3 deletions

View File

@ -161,9 +161,6 @@ public class FieldValueFactorFunction extends ScoreFunction {
@Override
public String toString() {
if (this == NONE) {
return "";
}
return super.toString().toLowerCase(Locale.ROOT);
}
}

View File

@ -69,6 +69,14 @@ public class FunctionScoreFieldValueTests extends ElasticsearchIntegrationTest {
.get();
assertOrderedSearchHits(response, "2", "1");
// try again, but this time explicitly use the do-nothing modifier
response = client().prepareSearch("test")
.setExplain(randomBoolean())
.setQuery(functionScoreQuery(simpleQueryStringQuery("foo"),
fieldValueFactorFunction("test").modifier(FieldValueFactorFunction.Modifier.NONE)))
.get();
assertOrderedSearchHits(response, "2", "1");
// document 1 scores higher because 1/5 > 1/17
response = client().prepareSearch("test")
.setExplain(randomBoolean())