Skip to content

Commit

Permalink
Improve boosting for name fields
Browse files Browse the repository at this point in the history
Don't apply full queryString to preferredName field
See #32

But retain boosting, and add variantName field
See #20
  • Loading branch information
fsteeg committed Oct 17, 2017
1 parent 36a0d3d commit eb6ea22
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions app/modules/IndexComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.query.MatchQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.QueryStringQueryBuilder;
import org.elasticsearch.node.Node;
Expand Down Expand Up @@ -196,10 +194,8 @@ private static void executeBulk(int pendingIndexRequests) {

@Override
public SearchResponse query(String q, int from, int size) {
MatchQueryBuilder preferredName = QueryBuilders.matchQuery("preferredName", q).boost(2);
QueryStringQueryBuilder queryStringQuery = QueryBuilders.queryStringQuery(q);
QueryBuilder query = QueryBuilders.boolQuery().should(preferredName).must(queryStringQuery)
.minimumNumberShouldMatch(0);
QueryStringQueryBuilder query = QueryBuilders.queryStringQuery(q).field("_all").field("preferredName", 5)
.field("variantName", 5);
SearchRequestBuilder requestBuilder = client().prepareSearch(config("index.name")).setQuery(query).setFrom(from)
.setSize(size);
requestBuilder.addAggregation(
Expand Down

0 comments on commit eb6ea22

Please sign in to comment.