SOLR-10792: remove OldLuceneQParser (FINALLY deprecated in 7.0) from master

This commit is contained in:
Chris Hostetter 2017-09-06 16:24:11 -07:00
parent 5e83475f9d
commit ba9504d49d
7 changed files with 36 additions and 141 deletions

View File

@ -16,13 +16,9 @@
*/ */
package org.apache.solr.search; 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.params.SolrParams;
import org.apache.solr.common.util.StrUtils;
import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.request.SolrQueryRequest;
import java.util.List;
/** /**
* Parse Solr's variant on the Lucene QueryParser syntax. * Parse Solr's variant on the Lucene QueryParser syntax.
* <br>Other parameters:<ul> * <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;
}
}

View File

@ -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);
}
}

View File

@ -489,9 +489,6 @@
<queryParser name="foo" class="FooQParserPlugin"/> <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"> <updateRequestProcessorChain name="dedupe">
<processor class="org.apache.solr.update.processor.SignatureUpdateProcessorFactory"> <processor class="org.apache.solr.update.processor.SignatureUpdateProcessorFactory">
<bool name="enabled">false</bool> <bool name="enabled">false</bool>

View File

@ -43,7 +43,6 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
SolrQueryRequest req = null; SolrQueryRequest req = null;
Map<String,String> args = new HashMap<>(); Map<String,String> args = new HashMap<>();
lrf.args.put(CommonParams.VERSION,"2.2"); lrf.args.put(CommonParams.VERSION,"2.2");
lrf.args.put("defType","lucenePlusSort");
// compact the index, keep things from getting out of hand // compact the index, keep things from getting out of hand
@ -215,16 +214,16 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"*[count(//doc)=0]" ,"*[count(//doc)=0]"
); );
args = new HashMap<>(); args = new HashMap<>();
args.put("defType","lucenePlusSort"); args.put("sort","val_s1 asc");
req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z];val_s1 asc", req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
"/select", 0, 0 , args); "/select", 0, 0 , args);
assertQ(req assertQ(req
,"//*[@numFound='3'] " ,"//*[@numFound='3'] "
,"*[count(//doc)=0]" ,"*[count(//doc)=0]"
); );
args = new HashMap<>(); args = new HashMap<>();
args.put("defType","lucenePlusSort"); args.put("sort","val_s1 desc");
req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z];val_s1 desc", req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
"/select", 0, 0 , args); "/select", 0, 0 , args);
assertQ(req assertQ(req
,"//*[@numFound='3'] " ,"//*[@numFound='3'] "
@ -518,11 +517,11 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"//@numFound[.='1'] " ,"//@numFound[.='1'] "
,"//int[.='-2147483648']" ,"//int[.='-2147483648']"
); );
assertQ(req("id:44;num_i1 asc;") assertQ(req("q", "id:44", "sort","num_i1 asc")
,"//doc[1]/int[.='-2147483648'] " ,"//doc[1]/int[.='-2147483648'] "
,"//doc[last()]/int[.='2147483647']" ,"//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[1]/int[.='2147483647'] "
,"//doc[last()]/int[.='-2147483648']" ,"//doc[last()]/int[.='-2147483648']"
); );
@ -561,11 +560,11 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"//@numFound[.='1'] " ,"//@numFound[.='1'] "
,"//long[.='-9223372036854775808']" ,"//long[.='-9223372036854775808']"
); );
assertQ(req("id:44;num_l1 asc;") assertQ(req("q","id:44","sort","num_l1 asc")
,"//doc[1]/long[.='-9223372036854775808'] " ,"//doc[1]/long[.='-9223372036854775808'] "
,"//doc[last()]/long[.='9223372036854775807']" ,"//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[1]/long[.='9223372036854775807'] "
,"//doc[last()]/long[.='-9223372036854775808']" ,"//doc[last()]/long[.='-9223372036854775808']"
); );
@ -611,11 +610,11 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
assertQ(req("num_f1:\"-1e20\"") assertQ(req("num_f1:\"-1e20\"")
,"//@numFound[.='1']" ,"//@numFound[.='1']"
); );
assertQ(req("id:44;num_f1 asc;") assertQ(req("q", "id:44", "sort", "num_f1 asc")
,"//doc[1]/float[.='-Infinity'] " ,"//doc[1]/float[.='-Infinity'] "
,"//doc[last()]/float[.='NaN']" ,"//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[1]/float[.='NaN'] "
,"//doc[last()]/float[.='-Infinity']" ,"//doc[last()]/float[.='-Infinity']"
); );
@ -663,11 +662,11 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
assertQ(req("num_d1:\"1e-100\"") assertQ(req("num_d1:\"1e-100\"")
,"//@numFound[.='1']" ,"//@numFound[.='1']"
); );
assertQ(req("id:44;num_d1 asc;") assertQ(req("q", "id:44", "sort", "num_d1 asc")
,"//doc[1]/double[.='-Infinity'] " ,"//doc[1]/double[.='-Infinity'] "
,"//doc[last()]/double[.='NaN']" ,"//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[1]/double[.='NaN'] "
,"//doc[last()]/double[.='-Infinity']" ,"//doc[last()]/double[.='-Infinity']"
); );
@ -693,27 +692,27 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
,"*[count(//doc)=6]" ,"*[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] " ,"*[count(//doc)=6] "
,"//doc[3]/int[.='100'] " ,"//doc[3]/int[.='100'] "
,"//doc[4]/int[.='50']" ,"//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] " ,"*[count(//doc)=6] "
,"//doc[3]/int[.='50'] " ,"//doc[3]/int[.='50'] "
,"//doc[4]/int[.='100']" ,"//doc[4]/int[.='100']"
); );
assertQ(req("id:44;a_i1 asc;") assertQ(req("q", "id:44", "sort", "a_i1 asc")
,"*[count(//doc)=6] " ,"*[count(//doc)=6] "
,"//doc[1]/int[.='-1'] " ,"//doc[1]/int[.='-1'] "
,"//doc[last()]/int[.='15']" ,"//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] " ,"*[count(//doc)=6] "
,"//doc[1]/int[.='-1'] " ,"//doc[1]/int[.='-1'] "
,"//doc[last()]/int[.='15']" ,"//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] " ,"*[count(//doc)=6] "
,"//doc[last()]/int[.='-1'] " ,"//doc[last()]/int[.='-1'] "
,"//doc[1]/int[.='15'] " ,"//doc[1]/int[.='15'] "
@ -736,36 +735,36 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
assertQ(req("id_i:[1000 TO 1010]") assertQ(req("id_i:[1000 TO 1010]")
,"*[count(//doc)=7]" ,"*[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] " ,"*[count(//doc)=7] "
,"//doc[1]/int[.='50'] " ,"//doc[1]/int[.='50'] "
,"//doc[2]/int[.='100']" ,"//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] " ,"*[count(//doc)=7] "
,"//doc[1]/int[.='100'] " ,"//doc[1]/int[.='100'] "
,"//doc[2]/int[.='50']" ,"//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] " ,"*[count(//doc)=7] "
,"//doc[3]/int[@name='b_i1' and .='100'] " ,"//doc[3]/int[@name='b_i1' and .='100'] "
,"//doc[4]/int[@name='b_i1' and .='50'] " ,"//doc[4]/int[@name='b_i1' and .='50'] "
,"//doc[5]/arr[@name='id_i' and .='1000']" ,"//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] " ,"*[count(//doc)=7] "
,"//doc[3]/int[@name='b_i1' and .='50'] " ,"//doc[3]/int[@name='b_i1' and .='50'] "
,"//doc[4]/int[@name='b_i1' and .='100'] " ,"//doc[4]/int[@name='b_i1' and .='100'] "
,"//doc[5]/arr[@name='id_i' and .='1000']" ,"//doc[5]/arr[@name='id_i' and .='1000']"
); );
// nullfirst tests // 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] " ,"*[count(//doc)=3] "
,"//doc[1]/arr[@name='id_i' and .='1002']" ,"//doc[1]/arr[@name='id_i' and .='1002']"
,"//doc[2]/arr[@name='id_i' and .='1001'] " ,"//doc[2]/arr[@name='id_i' and .='1001'] "
,"//doc[3]/arr[@name='id_i' and .='1000']" ,"//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] " ,"*[count(//doc)=3] "
,"//doc[1]/arr[@name='id_i' and .='1002']" ,"//doc[1]/arr[@name='id_i' and .='1002']"
,"//doc[2]/arr[@name='id_i' and .='1000'] " ,"//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) // Sort parsing exception tests. (SOLR-6, SOLR-99)
assertQEx( "can not sort unindexed fields", 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", assertQEx( "invalid query format",
req( "id_i:1000; nullfirst" ), 400 ); req( "q","id_i:1000", "sort", "nullfirst" ), 400 );
assertQEx( "unknown sort field", assertQEx( "unknown sort field",
req( "id_i:1000; abcde12345 asc" ), 400 ); req( "q","id_i:1000", "sort", "abcde12345 asc" ), 400 );
assertQEx( "unknown sort order", assertQEx( "unknown sort order",
req( "id_i:1000; nullfirst aaa" ), 400 ); req( "q","id_i:1000", "sort", "nullfirst aaa" ), 400 );
resetExceptionIgnores(); resetExceptionIgnores();
@ -1166,32 +1165,31 @@ public class ConvertedLegacyTest extends SolrTestCaseJ4 {
); );
args = new HashMap<>(); args = new HashMap<>();
args.put("fl","score "); args.put("fl","score ");
args.put("defType","lucenePlusSort"); args.put("sort","id desc");
req = new LocalSolrQueryRequest(h.getCore(), "id:44;id desc;", req = new LocalSolrQueryRequest(h.getCore(), "id:44",
"/select", 0, 10, args); "/select", 0, 10, args);
assertQ(req assertQ(req
,"//result[@maxScore>0]" ,"//result[@maxScore>0]"
); );
args = new HashMap<>(); args = new HashMap<>();
args.put("fl","score "); 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); "/select", 0, 10, args);
assertQ(req assertQ(req
,"//@maxScore = //doc/float[@name='score']" ,"//@maxScore = //doc/float[@name='score']"
); );
args = new HashMap<>(); args = new HashMap<>();
args.put("fl","score "); args.put("fl","score ");
args.put("defType","lucenePlusSort"); args.put("sort","id desc");
req = new LocalSolrQueryRequest(h.getCore(), "id:44;id desc;", req = new LocalSolrQueryRequest(h.getCore(), "id:44",
"/select", 0, 10, args); "/select", 0, 10, args);
assertQ(req assertQ(req
,"//@maxScore = //doc/float[@name='score']" ,"//@maxScore = //doc/float[@name='score']"
); );
args = new HashMap<>(); args = new HashMap<>();
args.put("fl","*,score"); args.put("fl","*,score");
args.put("defType","lucenePlusSort"); args.put("sort","id desc");
req = new LocalSolrQueryRequest(h.getCore(), "id:44;id desc;", req = new LocalSolrQueryRequest(h.getCore(), "id:44",
"/select", 0, 0 , args); "/select", 0, 0 , args);
assertQ(req assertQ(req
,"//result[@maxScore>0]" ,"//result[@maxScore>0]"

View File

@ -63,14 +63,14 @@ public class SearchHandlerTest extends AbstractSolrTestCase {
); );
// Using legacy ';' param // Using legacy ';' param
assertQ(req("q", "title:test; val_s1 desc", "defType","lucenePlusSort") assertQ(req("q", "title:test", "sort","val_s1 desc")
,"//*[@numFound='3']" ,"//*[@numFound='3']"
,"//result/doc[1]/str[@name='id'][.='12']" ,"//result/doc[1]/str[@name='id'][.='12']"
,"//result/doc[2]/str[@name='id'][.='11']" ,"//result/doc[2]/str[@name='id'][.='11']"
,"//result/doc[3]/str[@name='id'][.='10']" ,"//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']" ,"//*[@numFound='3']"
,"//result/doc[1]/str[@name='id'][.='10']" ,"//result/doc[1]/str[@name='id'][.='10']"
,"//result/doc[2]/str[@name='id'][.='11']" ,"//result/doc[2]/str[@name='id'][.='11']"

View File

@ -94,14 +94,6 @@ public class QueryEqualityTest extends SolrTestCaseJ4 {
" +apache +solr"); " +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 { public void testQueryPrefix() throws Exception {
SolrQueryRequest req = req("myField","foo_s"); SolrQueryRequest req = req("myField","foo_s");
try { try {

View File

@ -43,7 +43,6 @@ public class QueryParsingTest extends SolrTestCaseJ4 {
SolrQueryRequest req = req("df", "text"); SolrQueryRequest req = req("df", "text");
final String[] parsersTested = new String[] { final String[] parsersTested = new String[] {
OldLuceneQParserPlugin.NAME,
LuceneQParserPlugin.NAME, LuceneQParserPlugin.NAME,
DisMaxQParserPlugin.NAME, DisMaxQParserPlugin.NAME,
ExtendedDismaxQParserPlugin.NAME ExtendedDismaxQParserPlugin.NAME