From 32c63cea8e2d6cbd787a13607de30cab5380bf8d Mon Sep 17 00:00:00 2001 From: "Chris M. Hostetter" Date: Sat, 28 Feb 2009 00:36:30 +0000 Subject: [PATCH] SOLR-1036: Change default QParser from "lucenePlusSort" to "lucene" git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@748763 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 11 +++++++++++ .../apache/solr/handler/component/QueryComponent.java | 2 +- src/java/org/apache/solr/search/QParserPlugin.java | 4 ++-- src/test/org/apache/solr/ConvertedLegacyTest.java | 7 +++++++ .../solr/handler/StandardRequestHandlerTest.java | 2 ++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index a0e9d46d578..4898bb77b8a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -32,6 +32,14 @@ the index smaller and faster. If you are upgrading from an earlier Solr release and want to enable omitTf by default, change the schema version from 1.1 to 1.2 in schema.xml. Remove any existing index and restart Solr to ensure that omitTf completely takes affect. +The default QParserPlugin used by the QueryComponent for parsing the "q" param +has been changed, to remove support for the deprecated use of ";" as a separator +between the query string and the sort options when no "sort" param was used. +Users who wish to continue using the semi-colon based method of specifying the +sort options should explicitly set the defType param to "lucenePlusSort" on all +requests. (The simplest way to do this is by specifying it as a default param +for your request handlers in solrconfig.xml, see the example solrconfig.xml for +sample syntax.) Detailed Change List ---------------------- @@ -330,6 +338,9 @@ Other Changes 19. SOLR-967: New type-safe constructor for NamedList (Kay Kay via hossman) +20. SOLR-1036: Change default QParser from "lucenePlusSort" to "lucene" to + reduce confusion of semicolon splitting behavior when no sort param is + specified (hossman) Build ---------------------- diff --git a/src/java/org/apache/solr/handler/component/QueryComponent.java b/src/java/org/apache/solr/handler/component/QueryComponent.java index 7cfe7a17fe7..d165e537b54 100644 --- a/src/java/org/apache/solr/handler/component/QueryComponent.java +++ b/src/java/org/apache/solr/handler/component/QueryComponent.java @@ -75,7 +75,7 @@ public class QueryComponent extends SearchComponent rb.setFieldFlags( fieldFlags ); String defType = params.get(QueryParsing.DEFTYPE); - defType = defType==null ? OldLuceneQParserPlugin.NAME : defType; + defType = defType==null ? QParserPlugin.DEFAULT_QTYPE : defType; if (rb.getQueryString() == null) { rb.setQueryString( params.get( CommonParams.Q ) ); diff --git a/src/java/org/apache/solr/search/QParserPlugin.java b/src/java/org/apache/solr/search/QParserPlugin.java index 59ee23c9530..2fd8f6eaec9 100755 --- a/src/java/org/apache/solr/search/QParserPlugin.java +++ b/src/java/org/apache/solr/search/QParserPlugin.java @@ -22,11 +22,11 @@ import org.apache.solr.util.plugin.NamedListInitializedPlugin; public abstract class QParserPlugin implements NamedListInitializedPlugin { /** internal use - name of the default parser */ - public static String DEFAULT_QTYPE="lucene"; + public static String DEFAULT_QTYPE = LuceneQParserPlugin.NAME; /** internal use - name to class mappings of builtin parsers */ public static final Object[] standardPlugins = { - DEFAULT_QTYPE, LuceneQParserPlugin.class, + LuceneQParserPlugin.NAME, LuceneQParserPlugin.class, OldLuceneQParserPlugin.NAME, OldLuceneQParserPlugin.class, FunctionQParserPlugin.NAME, FunctionQParserPlugin.class, PrefixQParserPlugin.NAME, PrefixQParserPlugin.class, diff --git a/src/test/org/apache/solr/ConvertedLegacyTest.java b/src/test/org/apache/solr/ConvertedLegacyTest.java index 8f3e16de882..db97d317b3a 100644 --- a/src/test/org/apache/solr/ConvertedLegacyTest.java +++ b/src/test/org/apache/solr/ConvertedLegacyTest.java @@ -39,6 +39,7 @@ public class ConvertedLegacyTest extends AbstractSolrTestCase { SolrQueryRequest req = null; Map args = new HashMap(); lrf.args.put("version","2.0"); + lrf.args.put("defType","lucenePlusSort"); // compact the index, keep things from getting out of hand @@ -222,6 +223,7 @@ public class ConvertedLegacyTest extends AbstractSolrTestCase { ); args = new HashMap(); args.put("version","2.0"); + args.put("defType","lucenePlusSort"); req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z];val_s asc", "standard", 0, 0 , args); assertQ(req @@ -230,6 +232,7 @@ public class ConvertedLegacyTest extends AbstractSolrTestCase { ); args = new HashMap(); args.put("version","2.0"); + args.put("defType","lucenePlusSort"); req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z];val_s desc", "standard", 0, 0 , args); assertQ(req @@ -1171,6 +1174,7 @@ public class ConvertedLegacyTest extends AbstractSolrTestCase { args = new HashMap(); args.put("version","2.0"); args.put("fl","score "); + args.put("defType","lucenePlusSort"); req = new LocalSolrQueryRequest(h.getCore(), "id:44;id desc;", "standard", 0, 10, args); assertQ(req @@ -1179,6 +1183,7 @@ public class ConvertedLegacyTest extends AbstractSolrTestCase { args = new HashMap(); args.put("version","2.0"); args.put("fl","score "); + args.put("defType","lucenePlusSort"); req = new LocalSolrQueryRequest(h.getCore(), "id:44;", "standard", 0, 10, args); assertQ(req @@ -1187,6 +1192,7 @@ public class ConvertedLegacyTest extends AbstractSolrTestCase { args = new HashMap(); args.put("version","2.0"); args.put("fl","score "); + args.put("defType","lucenePlusSort"); req = new LocalSolrQueryRequest(h.getCore(), "id:44;id desc;", "standard", 0, 10, args); assertQ(req @@ -1195,6 +1201,7 @@ public class ConvertedLegacyTest extends AbstractSolrTestCase { args = new HashMap(); args.put("version","2.0"); args.put("fl","score"); + args.put("defType","lucenePlusSort"); req = new LocalSolrQueryRequest(h.getCore(), "id:44;id desc;", "standard", 0, 0 , args); assertQ(req diff --git a/src/test/org/apache/solr/handler/StandardRequestHandlerTest.java b/src/test/org/apache/solr/handler/StandardRequestHandlerTest.java index f12cc3891aa..e9dd455da55 100644 --- a/src/test/org/apache/solr/handler/StandardRequestHandlerTest.java +++ b/src/test/org/apache/solr/handler/StandardRequestHandlerTest.java @@ -25,6 +25,7 @@ import org.apache.solr.common.params.MapSolrParams; import org.apache.solr.core.SolrCore; import org.apache.solr.request.LocalSolrQueryRequest; import org.apache.solr.request.SolrQueryRequest; +import org.apache.solr.search.QueryParsing; import org.apache.solr.util.AbstractSolrTestCase; /** @@ -82,6 +83,7 @@ public class StandardRequestHandlerTest extends AbstractSolrTestCase { // Using legacy ';' param args.remove( CommonParams.SORT ); + args.put( QueryParsing.DEFTYPE, "lucenePlusSort" ); args.put( CommonParams.Q, "title:test; val_s desc" ); assertQ("with sort param [desc]", req ,"//*[@numFound='3']"