You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rj...@apache.org on 2014/04/26 00:18:25 UTC
svn commit: r1590166 - in /lucene/dev/trunk/solr: ./
core/src/java/org/apache/solr/search/
core/src/test-files/solr/collection1/conf/
core/src/test/org/apache/solr/search/
Author: rjernst
Date: Fri Apr 25 22:18:24 2014
New Revision: 1590166
URL: http://svn.apache.org/r1590166
Log:
SOLR-6017: Fix SimpleQParser to use query analyzer instead of index analyzer
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SimpleQParserPlugin.java
lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/schema-simpleqpplugin.xml
lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSimpleQParserPlugin.java
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1590166&r1=1590165&r2=1590166&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Fri Apr 25 22:18:24 2014
@@ -121,6 +121,9 @@ Bug Fixes
rollback as well as how SolrIndexWriter manages it's ref counted directory
instance. (Mark Miller, Gregory Chanan)
+* SOLR-6017: Fix SimpleQParser to use query analyzer instead of index analyzer.
+ (Ryan Ernst)
+
Other Changes
---------------------
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SimpleQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SimpleQParserPlugin.java?rev=1590166&r1=1590165&r2=1590166&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SimpleQParserPlugin.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SimpleQParserPlugin.java Fri Apr 25 22:18:24 2014
@@ -155,7 +155,7 @@ public class SimpleQParserPlugin extends
// Create a SimpleQueryParser using the analyzer from the schema.
final IndexSchema schema = req.getSchema();
- parser = new SolrSimpleQueryParser(req.getSchema().getAnalyzer(), queryFields, enabledOps, this, schema);
+ parser = new SolrSimpleQueryParser(req.getSchema().getQueryAnalyzer(), queryFields, enabledOps, this, schema);
// Set the default operator to be either 'AND' or 'OR' for the query.
QueryParser.Operator defaultOp = QueryParsing.getQueryParserDefaultOperator(req.getSchema(), defaultParams.get(QueryParsing.OP));
Modified: lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/schema-simpleqpplugin.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/schema-simpleqpplugin.xml?rev=1590166&r1=1590165&r2=1590166&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/schema-simpleqpplugin.xml (original)
+++ lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/schema-simpleqpplugin.xml Fri Apr 25 22:18:24 2014
@@ -38,6 +38,18 @@
<tokenizer class="solr.MockTokenizerFactory" pattern="keyword"/>
</analyzer>
</fieldtype>
+
+ <!-- basic text field: except it will use the keyword analyzer -->
+ <fieldtype name="text-query" class="solr.TextField">
+ <analyzer type="index">
+ <tokenizer class="solr.MockTokenizerFactory" pattern="whitespace"/>
+ </analyzer>
+ <!-- only lower case at query time, so we can check the query analyzer is used -->
+ <analyzer type="query">
+ <tokenizer class="solr.MockTokenizerFactory" pattern="whitespace"/>
+ <filter class="solr.LowerCaseFilterFactory"/>
+ </analyzer>
+ </fieldtype>
</types>
<fields>
@@ -45,6 +57,7 @@
<field name="text0" type="text" indexed="true" stored="true"/>
<field name="text1" type="text" indexed="true" stored="true"/>
<field name="text-keyword0" type="text-keyword" indexed="true" stored="true"/>
+ <field name="text-query0" type="text-query" indexed="true" stored="true"/>
</fields>
<defaultSearchField>text0</defaultSearchField>
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSimpleQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSimpleQParserPlugin.java?rev=1590166&r1=1590165&r2=1590166&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSimpleQParserPlugin.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSimpleQParserPlugin.java Fri Apr 25 22:18:24 2014
@@ -49,6 +49,8 @@ public class TestSimpleQParserPlugin ext
assertU(adoc("id", "55", "text0", "whitespace", "text1", "whitespace", "text-keyword0", " "));
assertU(adoc("id", "56", "text0", "whitespace", "text1", "whitespace", "text-keyword0", "\n"));
assertU(adoc("id", "57", "text0", "foobar", "text1", "foo bar", "text-keyword0", "fb"));
+ assertU(adoc("id", "58", "text-query0", "HELLO"));
+ assertU(adoc("id", "59", "text-query0", "hello"));
assertU(commit());
}
@@ -217,4 +219,10 @@ public class TestSimpleQParserPlugin ext
assertJQ(req("defType", "simple", "qf", "text0", "q", "FOO*"), "/response/numFound==1");
assertJQ(req("defType", "simple", "qf", "text0", "q", "BAR*"), "/response/numFound==0");
}
+
+ public void testQueryAnalyzerIsUsed() throws Exception {
+ // this should only match one doc, which was lower cased before being added
+ assertJQ(req("defType", "simple", "qf", "text-query0", "q", "HELLO"),
+ "/response/numFound==1");
+ }
}