Skip to content

Commit

Permalink
ensure all synonym queries have equal standing in the parsed query, s…
Browse files Browse the repository at this point in the history
…o synonyms aren't penalized when there are >2, fixes #33
  • Loading branch information
nolanlawson committed Nov 1, 2013
1 parent 26330c0 commit ce99a8e
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,18 +372,18 @@ private void applySynonymQueries(Query query, List<Query> synonymQueries, float
Query mainUserQuery = booleanClause.getQuery();
mainUserQuery.setBoost(originalBoost);

// combine all synonym queries together with the same boost
BooleanQuery allSynonymQueries = new BooleanQuery();
// add all synonyms queries separately, each with the synonym boost
BooleanQuery combinedQuery = new BooleanQuery();
combinedQuery.add(mainUserQuery, Occur.SHOULD);

for (Query synonymQuery : synonymQueries) {
allSynonymQueries.add(synonymQuery, Occur.SHOULD);
BooleanQuery booleanSynonymQuery = new BooleanQuery();
booleanSynonymQuery.add(synonymQuery, Occur.SHOULD);
booleanSynonymQuery.setBoost(synonymBoost);

combinedQuery.add(booleanSynonymQuery, Occur.SHOULD);
}

allSynonymQueries.setBoost(synonymBoost);

// now combine with the original main user query
BooleanQuery combinedQuery = new BooleanQuery();
combinedQuery.add(mainUserQuery, Occur.SHOULD);
combinedQuery.add(allSynonymQueries, Occur.SHOULD);
booleanClause.setQuery(combinedQuery);
queryToHighlight = combinedQuery;
}
Expand Down

0 comments on commit ce99a8e

Please sign in to comment.