Apache Lucene open-source search software
SOLR-10792: remove OldLuceneQParser (FINALLY deprecated in 7.0) from master
Chris Hostetterba9504d49dea
diff --git a/solr/core/src/java/org/apache/solr/search/LuceneQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/LuceneQParserPlugin.javaindex 912b57f4dfd..91c824a7a88 100644--- a/solr/core/src/java/org/apache/solr/search/LuceneQParserPlugin.java+++ b/solr/core/src/java/org/apache/solr/search/LuceneQParserPlugin.java@@ -16,13 +16,9 @@*/package org.apache.solr.search;-import org.apache.lucene.search.Query;-import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.SolrParams;-import org.apache.solr.common.util.StrUtils;import org.apache.solr.request.SolrQueryRequest;-import java.util.List;/*** Parse Solr's variant on the Lucene QueryParser syntax.* <br>Other parameters:<ul>@@ -42,53 +38,3 @@ public class LuceneQParserPlugin extends QParserPlugin {}}-@Deprecated-class OldLuceneQParser extends LuceneQParser {- String sortStr;-- public OldLuceneQParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {- super(qstr, localParams, params, req);- }-- @Override- public Query parse() throws SyntaxError {- // handle legacy "query;sort" syntax- if (getLocalParams() == null) {- String qstr = getString();- if (qstr == null || qstr.length() == 0)- return null;- sortStr = getParams().get(CommonParams.SORT);- if (sortStr == null) {- // sort may be legacy form, included in the query string- List<String> commands = StrUtils.splitSmart(qstr,';');- if (commands.size() == 2) {- qstr = commands.get(0);- sortStr = commands.get(1);- } else if (commands.size() == 1) {- // This is need to support the case where someone sends: "q=query;"- qstr = commands.get(0);- }- else if (commands.size() > 2) {- throw new SyntaxError("If you want to use multiple ';' in the query, use the 'sort' param.");- }- }- setString(qstr);- }-- return super.parse();- }-- @Override- public SortSpec getSortSpec(boolean useGlobal) throws SyntaxError {- SortSpec sort = super.getSortSpec(useGlobal);- if (sortStr != null && sortStr.length()>0 && sort.getSort()==null) {- SortSpec oldSort = SortSpecParsing.parseSortSpec(sortStr, getReq());- if( oldSort.getSort() != null ) {- sort.setSortAndFields(oldSort.getSort(), oldSort.getSchemaFields());- }- }- return sort;- }--}-diff --git a/solr/core/src/java/org/apache/solr/search/OldLuceneQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/OldLuceneQParserPlugin.javadeleted file mode 100644index d4cbfcbd857..00000000000--- a/solr/core/src/java/org/apache/solr/search/OldLuceneQParserPlugin.java+++ /dev/null@@ -1,37 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */-package org.apache.solr.search;--import org.apache.solr.common.params.SolrParams;-import org.apache.solr.request.SolrQueryRequest;--/**- * Parse Solr's variant of Lucene QueryParser syntax, including the- * deprecated sort specification after the query.- * <br>Example: <code>{!lucenePlusSort}myfield:foo +bar -baz;price asc</code>- *- * @deprecated This class should have been removed a long time ago, it will be removed in Solr 8.0- */-@Deprecated-public class OldLuceneQParserPlugin extends QParserPlugin {- public static final String NAME = "lucenePlusSort";-- @Override- public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {- return new OldLuceneQParser(qstr, localParams, params, req);- }-}diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig.xmlindex 9422a4d8e79..6528abad706 100644--- a/solr/core/src/test-files/solr/collection1/conf/solrconfig.xml+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig.xml@@ -489,9 +489,6 @@<queryParser name="foo" class="FooQParserPlugin"/>- <!-- deprecated parser, delete once class is deleted in Solr 8.0 -->- <queryParser name="lucenePlusSort" class="solr.OldLuceneQParserPlugin"/>-<updateRequestProcessorChain name="dedupe"><processor class="org.apache.solr.update.processor.SignatureUpdateProcessorFactory"><bool name="enabled">false</bool>diff --git a/solr/core/src/test/org/apache/solr/ConvertedLegacyTest.java b/solr/core/src/test/org/apache/solr/ConvertedLegacyTest.javaindex 35bd1073fd0..603dd03d89f 100644--- a/solr/core/src/test/org/apache/solr/ConvertedLegacyTest.java+++ b/solr/core/src/test/org/apache/solr/ConvertedLegacyTest.java@@ -43,7 +43,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {SolrQueryRequest req = null;Map<String,String> args = new HashMap<>();lrf.args.put(CommonParams.VERSION,"2.2");- lrf.args.put("defType","lucenePlusSort");// compact the index, keep things from getting out of hand@@ -215,16 +214,16 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {,"*[count(//doc)=0]");args = new HashMap<>();- args.put("defType","lucenePlusSort");- req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z];val_s1 asc",+ args.put("sort","val_s1 asc");+ req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]","/select", 0, 0 , args);assertQ(req,"//*[@numFound='3'] ","*[count(//doc)=0]");args = new HashMap<>();- args.put("defType","lucenePlusSort");- req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z];val_s1 desc",+ args.put("sort","val_s1 desc");+ req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]","/select", 0, 0 , args);assertQ(req,"//*[@numFound='3'] "@@ -518,11 +517,11 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {,"//@numFound[.='1'] ","//int[.='-2147483648']");- assertQ(req("id:44;num_i1 asc;")+ assertQ(req("q", "id:44", "sort","num_i1 asc"),"//doc[1]/int[.='-2147483648'] ","//doc[last()]/int[.='2147483647']");- assertQ(req("id:44;num_i1 desc;")+ assertQ(req("q","id:44","sort","num_i1 desc"),"//doc[1]/int[.='2147483647'] ","//doc[last()]/int[.='-2147483648']");@@ -561,11 +560,11 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {,"//@numFound[.='1'] ","//long[.='-9223372036854775808']");- assertQ(req("id:44;num_l1 asc;")+ assertQ(req("q","id:44","sort","num_l1 asc"),"//doc[1]/long[.='-9223372036854775808'] ","//doc[last()]/long[.='9223372036854775807']");- assertQ(req("id:44;num_l1 desc;")+ assertQ(req("q","id:44", "sort", "num_l1 desc"),"//doc[1]/long[.='9223372036854775807'] ","//doc[last()]/long[.='-9223372036854775808']");@@ -611,11 +610,11 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {assertQ(req("num_f1:\"-1e20\""),"//@numFound[.='1']");- assertQ(req("id:44;num_f1 asc;")+ assertQ(req("q", "id:44", "sort", "num_f1 asc"),"//doc[1]/float[.='-Infinity'] ","//doc[last()]/float[.='NaN']");- assertQ(req("id:44;num_f1 desc;")+ assertQ(req("q", "id:44", "sort","num_f1 desc"),"//doc[1]/float[.='NaN'] ","//doc[last()]/float[.='-Infinity']");@@ -663,11 +662,11 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {assertQ(req("num_d1:\"1e-100\""),"//@numFound[.='1']");- assertQ(req("id:44;num_d1 asc;")+ assertQ(req("q", "id:44", "sort", "num_d1 asc"),"//doc[1]/double[.='-Infinity'] ","//doc[last()]/double[.='NaN']");- assertQ(req("id:44;num_d1 desc;")+ assertQ(req("q","id:44","sort","num_d1 desc"),"//doc[1]/double[.='NaN'] ","//doc[last()]/double[.='-Infinity']");@@ -693,27 +692,27 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {,"*[count(//doc)=6]");- assertQ(req("id:44; a_i1 asc,b_i1 desc")+ assertQ(req("q","id:44", "sort", "a_i1 asc,b_i1 desc"),"*[count(//doc)=6] ","//doc[3]/int[.='100'] ","//doc[4]/int[.='50']");- assertQ(req("id:44;a_i1 asc , b_i1 asc;")+ assertQ(req("q","id:44", "sort", "a_i1 asc , b_i1 asc"),"*[count(//doc)=6] ","//doc[3]/int[.='50'] ","//doc[4]/int[.='100']");- assertQ(req("id:44;a_i1 asc;")+ assertQ(req("q", "id:44", "sort", "a_i1 asc"),"*[count(//doc)=6] ","//doc[1]/int[.='-1'] ","//doc[last()]/int[.='15']");- assertQ(req("id:44;a_i1 asc , score top;")+ assertQ(req("q","id:44","sort","a_i1 asc , score top"),"*[count(//doc)=6] ","//doc[1]/int[.='-1'] ","//doc[last()]/int[.='15']");- assertQ(req("id:44; score top , a_i1 top, b_i1 bottom ;")+ assertQ(req("q","id:44","sort","score top , a_i1 top, b_i1 bottom "),"*[count(//doc)=6] ","//doc[last()]/int[.='-1'] ","//doc[1]/int[.='15'] "@@ -736,36 +735,36 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {assertQ(req("id_i:[1000 TO 1010]"),"*[count(//doc)=7]");- assertQ(req("id_i:[1000 TO 1010]; b_i1 asc")+ assertQ(req("q","id_i:[1000 TO 1010]","sort","b_i1 asc"),"*[count(//doc)=7] ","//doc[1]/int[.='50'] ","//doc[2]/int[.='100']");- assertQ(req("id_i:[1000 TO 1010]; b_i1 desc")+ assertQ(req("q","id_i:[1000 TO 1010]","sort"," b_i1 desc"),"*[count(//doc)=7] ","//doc[1]/int[.='100'] ","//doc[2]/int[.='50']");- assertQ(req("id_i:[1000 TO 1010]; a_i1 asc,b_i1 desc")+ assertQ(req("q","id_i:[1000 TO 1010]","sort"," a_i1 asc,b_i1 desc"),"*[count(//doc)=7] ","//doc[3]/int[@name='b_i1' and .='100'] ","//doc[4]/int[@name='b_i1' and .='50'] ","//doc[5]/arr[@name='id_i' and .='1000']");- assertQ(req("id_i:[1000 TO 1010]; a_i1 asc,b_i1 asc")+ assertQ(req("q","id_i:[1000 TO 1010]","sort"," a_i1 asc,b_i1 asc"),"*[count(//doc)=7] ","//doc[3]/int[@name='b_i1' and .='50'] ","//doc[4]/int[@name='b_i1' and .='100'] ","//doc[5]/arr[@name='id_i' and .='1000']");// nullfirst tests- assertQ(req("id_i:[1000 TO 1002]; nullfirst asc")+ assertQ(req("q","id_i:[1000 TO 1002]","sort"," nullfirst asc"),"*[count(//doc)=3] ","//doc[1]/arr[@name='id_i' and .='1002']","//doc[2]/arr[@name='id_i' and .='1001'] ","//doc[3]/arr[@name='id_i' and .='1000']");- assertQ(req("id_i:[1000 TO 1002]; nullfirst desc")+ assertQ(req("q","id_i:[1000 TO 1002]","sort"," nullfirst desc"),"*[count(//doc)=3] ","//doc[1]/arr[@name='id_i' and .='1002']","//doc[2]/arr[@name='id_i' and .='1000'] "@@ -779,16 +778,16 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {// Sort parsing exception tests. (SOLR-6, SOLR-99)assertQEx( "can not sort unindexed fields",- req( "id_i:1000; shouldbeunindexed asc" ), 400 );+ req( "q","id_i:1000", "sort", "shouldbeunindexed asc" ), 400 );assertQEx( "invalid query format",- req( "id_i:1000; nullfirst" ), 400 );+ req( "q","id_i:1000", "sort", "nullfirst" ), 400 );assertQEx( "unknown sort field",- req( "id_i:1000; abcde12345 asc" ), 400 );+ req( "q","id_i:1000", "sort", "abcde12345 asc" ), 400 );assertQEx( "unknown sort order",- req( "id_i:1000; nullfirst aaa" ), 400 );+ req( "q","id_i:1000", "sort", "nullfirst aaa" ), 400 );resetExceptionIgnores();@@ -1166,32 +1165,31 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {);args = new HashMap<>();args.put("fl","score ");- args.put("defType","lucenePlusSort");- req = new LocalSolrQueryRequest(h.getCore(), "id:44;id desc;",+ args.put("sort","id desc");+ req = new LocalSolrQueryRequest(h.getCore(), "id:44","/select", 0, 10, args);assertQ(req,"//result[@maxScore>0]");args = new HashMap<>();args.put("fl","score ");- args.put("defType","lucenePlusSort");- req = new LocalSolrQueryRequest(h.getCore(), "id:44;",+ req = new LocalSolrQueryRequest(h.getCore(), "id:44","/select", 0, 10, args);assertQ(req,"//@maxScore = //doc/float[@name='score']");args = new HashMap<>();args.put("fl","score ");- args.put("defType","lucenePlusSort");- req = new LocalSolrQueryRequest(h.getCore(), "id:44;id desc;",+ args.put("sort","id desc");+ req = new LocalSolrQueryRequest(h.getCore(), "id:44","/select", 0, 10, args);assertQ(req,"//@maxScore = //doc/float[@name='score']");args = new HashMap<>();args.put("fl","*,score");- args.put("defType","lucenePlusSort");- req = new LocalSolrQueryRequest(h.getCore(), "id:44;id desc;",+ args.put("sort","id desc");+ req = new LocalSolrQueryRequest(h.getCore(), "id:44","/select", 0, 0 , args);assertQ(req,"//result[@maxScore>0]"diff --git a/solr/core/src/test/org/apache/solr/handler/SearchHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/SearchHandlerTest.javaindex b35103ba7ce..4fa5f10addd 100644--- a/solr/core/src/test/org/apache/solr/handler/SearchHandlerTest.java+++ b/solr/core/src/test/org/apache/solr/handler/SearchHandlerTest.java@@ -63,14 +63,14 @@ public class SearchHandlerTest extends AbstractSolrTestCase {);// Using legacy ';' param- assertQ(req("q", "title:test; val_s1 desc", "defType","lucenePlusSort")+ assertQ(req("q", "title:test", "sort","val_s1 desc"),"//*[@numFound='3']","//result/doc[1]/str[@name='id'][.='12']","//result/doc[2]/str[@name='id'][.='11']","//result/doc[3]/str[@name='id'][.='10']");- assertQ(req("q", "title:test; val_s1 asc", "defType","lucenePlusSort")+ assertQ(req("q", "title:test", "sort", "val_s1 asc"),"//*[@numFound='3']","//result/doc[1]/str[@name='id'][.='10']","//result/doc[2]/str[@name='id'][.='11']"diff --git a/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java b/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.javaindex eab254fb3f4..4177d81be60 100644--- a/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java+++ b/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java@@ -94,14 +94,6 @@ public class QueryEqualityTest extends SolrTestCaseJ4 {" +apache +solr");}- @Deprecated- public void testQueryLucenePlusSort() throws Exception {- assertQueryEquals("lucenePlusSort",- "apache solr", "apache solr", "apache solr ; score desc");- assertQueryEquals("lucenePlusSort",- "+apache +solr", "apache AND solr", " +apache +solr; score desc");- }-public void testQueryPrefix() throws Exception {SolrQueryRequest req = req("myField","foo_s");try {diff --git a/solr/core/src/test/org/apache/solr/search/QueryParsingTest.java b/solr/core/src/test/org/apache/solr/search/QueryParsingTest.javaindex 925f71b8108..20ea9412d59 100644--- a/solr/core/src/test/org/apache/solr/search/QueryParsingTest.java+++ b/solr/core/src/test/org/apache/solr/search/QueryParsingTest.java@@ -43,7 +43,6 @@ public class QueryParsingTest extends SolrTestCaseJ4 {SolrQueryRequest req = req("df", "text");final String[] parsersTested = new String[] {- OldLuceneQParserPlugin.NAME,LuceneQParserPlugin.NAME,DisMaxQParserPlugin.NAME,ExtendedDismaxQParserPlugin.NAME