From 835f533d08a5154097019eaa99ac77895655dabe Mon Sep 17 00:00:00 2001 From: alukanin Date: Wed, 7 Aug 2013 16:53:23 +0600 Subject: [PATCH 1/2] new option synonyms.ignoreQueryOperators (false by default) --- .../search/SynonymExpandingExtendedDismaxQParserPlugin.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/solr/search/SynonymExpandingExtendedDismaxQParserPlugin.java b/src/main/java/org/apache/solr/search/SynonymExpandingExtendedDismaxQParserPlugin.java index da3c1ec..b0959e0 100644 --- a/src/main/java/org/apache/solr/search/SynonymExpandingExtendedDismaxQParserPlugin.java +++ b/src/main/java/org/apache/solr/search/SynonymExpandingExtendedDismaxQParserPlugin.java @@ -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"; } @@ -292,7 +293,8 @@ private void attemptToApplySynonymsToQuery(Query query, SolrParams solrParams, A List 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 From 2bb47fcef6348f08fd2a574141b0e4c3d5253904 Mon Sep 17 00:00:00 2001 From: alukanin Date: Wed, 7 Aug 2013 17:06:51 +0600 Subject: [PATCH 2/2] incremented the build version and added the description of the new option --- README.md | 8 ++++++++ pom.xml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 10fc9d6..61fadf3 100644 --- a/README.md +++ b/README.md @@ -260,6 +260,12 @@ The following are parameters that you can use to tweak the synonym expansion. false v1.2.2+: 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 issue #5 for more discussion. + +synonyms.ignoreQueryOperators +boolean +false +v1.3.2+: If you treat query operators as usual words and want the synonyms be added to the query anyhow, set this option to True. + @@ -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 diff --git a/pom.xml b/pom.xml index 866c4c6..4e6c63f 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.healthonnet.lucene hon-lucene-synonyms - 1.3.1-solr-4.3.0 + 1.3.2-solr-4.3.0 org.apache.solr