Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A new option synonyms.ignoreQueryOperators #28

Merged
merged 2 commits into from
Oct 12, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -301,6 +307,8 @@ Currently I test against Solr 4.2.
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