make mult default boost mode
always multiply query score to function score. For script score functions, this means that boost_mode has to be set to `plain` if 'function_score' should behave like 'custom_score'
This commit is contained in:
parent
634f1036a0
commit
41c59c6b49
|
@ -68,7 +68,7 @@ public class FunctionScoreQueryParser implements QueryParser {
|
|||
|
||||
String currentFieldName = null;
|
||||
XContentParser.Token token;
|
||||
CombineFunction combineFunction = null;
|
||||
CombineFunction combineFunction = CombineFunction.MULT;
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentFieldName = parser.currentName();
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.action.search.SearchResponse;
|
|||
import org.elasticsearch.action.search.SearchType;
|
||||
import org.elasticsearch.action.search.ShardSearchFailure;
|
||||
import org.elasticsearch.common.Priority;
|
||||
import org.elasticsearch.common.lucene.search.function.CombineFunction;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.query.functionscore.script.ScriptScoreFunctionBuilder;
|
||||
|
@ -1218,7 +1219,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
|
|||
QueryBuilders.functionScoreQuery(
|
||||
matchQuery("c_field2", 0)
|
||||
).add(new ScriptScoreFunctionBuilder().script("doc['c_field1'].value")
|
||||
)).scoreType("sum")
|
||||
).boostMode(CombineFunction.PLAIN.getName())).scoreType("sum")
|
||||
)
|
||||
.execute().actionGet();
|
||||
|
||||
|
@ -1237,7 +1238,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
|
|||
QueryBuilders.functionScoreQuery(
|
||||
matchQuery("c_field2", 0)
|
||||
).add(new ScriptScoreFunctionBuilder().script("doc['c_field1'].value")
|
||||
)).scoreType("max")
|
||||
).boostMode(CombineFunction.PLAIN.getName())).scoreType("max")
|
||||
)
|
||||
.execute().actionGet();
|
||||
|
||||
|
@ -1256,7 +1257,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
|
|||
QueryBuilders.functionScoreQuery(
|
||||
matchQuery("c_field2", 0)
|
||||
).add(new ScriptScoreFunctionBuilder().script("doc['c_field1'].value")
|
||||
)).scoreType("avg")
|
||||
).boostMode(CombineFunction.PLAIN.getName())).scoreType("avg")
|
||||
)
|
||||
.execute().actionGet();
|
||||
|
||||
|
@ -1275,7 +1276,7 @@ public class SimpleChildQuerySearchTests extends AbstractSharedClusterTest {
|
|||
QueryBuilders.functionScoreQuery(
|
||||
matchQuery("p_field1", "p_value3")
|
||||
).add(new ScriptScoreFunctionBuilder().script("doc['p_field2'].value")
|
||||
)).scoreType("score")
|
||||
).boostMode(CombineFunction.PLAIN.getName())).scoreType("score")
|
||||
)
|
||||
.addSort(SortBuilders.fieldSort("c_field3"))
|
||||
.addSort(SortBuilders.scoreSort())
|
||||
|
|
|
@ -24,6 +24,7 @@ package org.elasticsearch.test.integration.search.rescore;
|
|||
import org.apache.lucene.util.English;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.search.SearchType;
|
||||
import org.elasticsearch.common.lucene.search.function.CombineFunction;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings.Builder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -481,9 +482,9 @@ public class QueryRescorerTests extends AbstractSharedClusterTest {
|
|||
.queryRescorer(
|
||||
QueryBuilders.boolQuery()
|
||||
.disableCoord(true)
|
||||
.should(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("field1", intToEnglish[0])).add(new ScriptScoreFunctionBuilder().script("5.0f")))
|
||||
.should(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("field1", intToEnglish[1])).add(new ScriptScoreFunctionBuilder().script("7.0f")))
|
||||
.should(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("field1", intToEnglish[3])).add(new ScriptScoreFunctionBuilder().script("0.0f"))))
|
||||
.should(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("field1", intToEnglish[0])).add(new ScriptScoreFunctionBuilder().script("5.0f")).boostMode(CombineFunction.PLAIN.getName()))
|
||||
.should(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("field1", intToEnglish[1])).add(new ScriptScoreFunctionBuilder().script("7.0f")).boostMode(CombineFunction.PLAIN.getName()))
|
||||
.should(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("field1", intToEnglish[3])).add(new ScriptScoreFunctionBuilder().script("0.0f")).boostMode(CombineFunction.PLAIN.getName())))
|
||||
.setQueryWeight(primaryWeight)
|
||||
.setRescoreQueryWeight(secondaryWeight);
|
||||
|
||||
|
@ -496,10 +497,10 @@ public class QueryRescorerTests extends AbstractSharedClusterTest {
|
|||
.setPreference("test") // ensure we hit the same shards for tie-breaking
|
||||
.setQuery(QueryBuilders.boolQuery()
|
||||
.disableCoord(true)
|
||||
.should(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("field1", intToEnglish[0])).add(new ScriptScoreFunctionBuilder().script("2.0f")))
|
||||
.should(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("field1", intToEnglish[1])).add(new ScriptScoreFunctionBuilder().script("3.0f")))
|
||||
.should(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("field1", intToEnglish[2])).add(new ScriptScoreFunctionBuilder().script("5.0f")))
|
||||
.should(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("field1", intToEnglish[3])).add(new ScriptScoreFunctionBuilder().script("0.2f"))))
|
||||
.should(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("field1", intToEnglish[0])).add(new ScriptScoreFunctionBuilder().script("2.0f")).boostMode(CombineFunction.PLAIN.getName()))
|
||||
.should(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("field1", intToEnglish[1])).add(new ScriptScoreFunctionBuilder().script("3.0f")).boostMode(CombineFunction.PLAIN.getName()))
|
||||
.should(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("field1", intToEnglish[2])).add(new ScriptScoreFunctionBuilder().script("5.0f")).boostMode(CombineFunction.PLAIN.getName()))
|
||||
.should(QueryBuilders.functionScoreQuery(QueryBuilders.termQuery("field1", intToEnglish[3])).add(new ScriptScoreFunctionBuilder().script("0.2f")).boostMode(CombineFunction.PLAIN.getName())))
|
||||
.setFrom(0)
|
||||
.setSize(10)
|
||||
.setRescorer(rescoreQuery)
|
||||
|
|
Loading…
Reference in New Issue