mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
Fixing review comments.
This commit is contained in:
parent
907cdc61f7
commit
5e9106ae5e
@ -39,7 +39,7 @@ public class SimpleQueryStringBuilder extends QueryBuilder implements BoostableQ
|
|||||||
private String queryName;
|
private String queryName;
|
||||||
private String minimumShouldMatch;
|
private String minimumShouldMatch;
|
||||||
private int flags = -1;
|
private int flags = -1;
|
||||||
private float boost = 1.0f;
|
private float boost = -1.0f;
|
||||||
private Boolean lowercaseExpandedTerms;
|
private Boolean lowercaseExpandedTerms;
|
||||||
private Boolean lenient;
|
private Boolean lenient;
|
||||||
private Boolean analyzeWildcard;
|
private Boolean analyzeWildcard;
|
||||||
@ -210,7 +210,7 @@ public class SimpleQueryStringBuilder extends QueryBuilder implements BoostableQ
|
|||||||
builder.field("minimum_should_match", minimumShouldMatch);
|
builder.field("minimum_should_match", minimumShouldMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boost != 1.0f) {
|
if (boost != -1.0f) {
|
||||||
builder.field("boost", boost);
|
builder.field("boost", boost);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,10 @@ public class SimpleQueryStringParser implements QueryParser {
|
|||||||
Queries.applyMinimumShouldMatch((BooleanQuery) query, minimumShouldMatch);
|
Queries.applyMinimumShouldMatch((BooleanQuery) query, minimumShouldMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (query != null) {
|
||||||
query.setBoost(boost);
|
query.setBoost(boost);
|
||||||
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,12 +60,14 @@ public class SimpleQueryStringTests extends ElasticsearchIntegrationTest {
|
|||||||
assertHitCount(searchResponse, 3l);
|
assertHitCount(searchResponse, 3l);
|
||||||
assertSearchHits(searchResponse, "1", "2", "3");
|
assertSearchHits(searchResponse, "1", "2", "3");
|
||||||
|
|
||||||
|
// Tests boost value setting. In this case doc 1 should always be ranked above the other
|
||||||
|
// two matches.
|
||||||
searchResponse = client().prepareSearch().setQuery(
|
searchResponse = client().prepareSearch().setQuery(
|
||||||
boolQuery()
|
boolQuery()
|
||||||
.should(simpleQueryStringQuery("foo").boost(-10.0f))
|
.should(simpleQueryStringQuery("\"foo bar\"").boost(10.0f))
|
||||||
.should(termQuery("body", "eggplant"))).get();
|
.should(termQuery("body", "eggplant"))).get();
|
||||||
assertHitCount(searchResponse, 3l);
|
assertHitCount(searchResponse, 2l);
|
||||||
assertFirstHit(searchResponse, hasId("4"));
|
assertFirstHit(searchResponse, hasId("3"));
|
||||||
|
|
||||||
searchResponse = client().prepareSearch().setQuery(
|
searchResponse = client().prepareSearch().setQuery(
|
||||||
simpleQueryStringQuery("foo bar").defaultOperator(SimpleQueryStringBuilder.Operator.AND)).get();
|
simpleQueryStringQuery("foo bar").defaultOperator(SimpleQueryStringBuilder.Operator.AND)).get();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user