Skip to content

Commit

Permalink
Merge pull request #28 from avlukanin/master
Browse files Browse the repository at this point in the history
A new option synonyms.ignoreQueryOperators
  • Loading branch information
nolanlawson committed Oct 12, 2013
2 parents 7f263e8 + 2bb47fc commit 1cf5048
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,12 @@ The following are parameters that you can use to tweak the synonym expansion.
<td style="padding:0 1em;"><font size="-1">false</font></td>
<td style="padding:0 1em;"><font size="-1"><strong>v1.2.2+:</strong> True if expanded synonyms should always be treated like phrases (i.e. wrapped in quotes). This option is offered in case your synonyms contain lots of phrases composed of common words (e.g. "man's best friend" for "dog"). Only affects the expanded synonyms; not the original query. See <a href='http://github.com/healthonnet/hon-lucene-synonyms/issues/5'>issue #5</a> for more discussion.</font></td>
</tr>
<tr>
<td style="padding:0 1em;"><strong><font face="monospace" size="-1">synonyms.ignoreQueryOperators</font></strong></td>
<td style="padding:0 1em;"><font size="-1">boolean</font></td>
<td style="padding:0 1em;"><font size="-1">false</font></td>
<td style="padding:0 1em;"><font size="-1"><strong>v1.3.2+:</strong> If you treat query operators as usual words and want the synonyms be added to the query anyhow, set this option to True.</font></td>
</tr>
</table>


Expand Down Expand Up @@ -304,6 +310,8 @@ nosetests test/
Changelog
------------

* v1.3.2
* Added synonyms.ignoreQueryOperators option
* v1.3.1
* Avoid luceneMatchVersion in config ([#20][220])
* v1.3.0
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.healthonnet.lucene</groupId>
<artifactId>hon-lucene-synonyms</artifactId>
<version>1.3.1-solr-4.3.0</version>
<version>1.3.2-solr-4.3.0</version>
<dependencies>
<dependency>
<groupId>org.apache.solr</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public static class Params {
public static final String SYNONYMS_SYNONYM_BOOST = "synonyms.synonymBoost";
public static final String SYNONYMS_DISABLE_PHRASE_QUERIES = "synonyms.disablePhraseQueries";
public static final String SYNONYMS_CONSTRUCT_PHRASES = "synonyms.constructPhrases";
public static final String SYNONYMS_IGNORE_QUERY_OPERATORS = "synonyms.ignoreQueryOperators";

}

Expand Down Expand Up @@ -292,7 +293,8 @@ private void attemptToApplySynonymsToQuery(Query query, SolrParams solrParams, A

List<Query> synonymQueries = generateSynonymQueries(synonymAnalyzer, solrParams);

boolean hasComplexQueryOperators = Const.COMPLEX_QUERY_OPERATORS_PATTERN.matcher(getQueryStringFromParser()).find();
boolean ignoreQueryOperators = solrParams.getBool(Params.SYNONYMS_IGNORE_QUERY_OPERATORS, false);
boolean hasComplexQueryOperators = ignoreQueryOperators ? false : Const.COMPLEX_QUERY_OPERATORS_PATTERN.matcher(getQueryStringFromParser()).find();

if (hasComplexQueryOperators // TODO: support complex operators
|| synonymQueries.isEmpty()) { // didn't find more than 0 synonyms, i.e. it's just the original phrase
Expand Down

0 comments on commit 1cf5048

Please sign in to comment.