mirror of https://github.com/apache/lucene.git
SOLR-13080: TermsQParserPlugin automaton method should (must?) sort input
This commit is contained in:
parent
207b3f4453
commit
1d0a086217
|
@ -182,6 +182,9 @@ Bug Fixes
|
|||
* SOLR-13072: Management of markers for nodeLost / nodeAdded events is broken. This bug could have caused
|
||||
some events to be lost if they coincided with an Overseer leader crash. (ab)
|
||||
|
||||
* SOLR-13080: The "terms" QParser's "automaton" method semi-required that the input terms/IDs be sorted. This
|
||||
query parser now does this. Unclear if this is a perf issue or actual bug. (Daniel Lowe, David Smiley)
|
||||
|
||||
Improvements
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.lucene.search.MatchNoDocsQuery;
|
|||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.TermInSetQuery;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.util.ArrayUtil;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.BytesRefBuilder;
|
||||
import org.apache.lucene.util.automaton.Automata;
|
||||
|
@ -79,7 +80,8 @@ public class TermsQParserPlugin extends QParserPlugin {
|
|||
automaton {
|
||||
@Override
|
||||
Query makeFilter(String fname, BytesRef[] byteRefs) {
|
||||
Automaton union = Automata.makeStringUnion(Arrays.asList(byteRefs));
|
||||
ArrayUtil.timSort(byteRefs); // same sort algo as TermInSetQuery's choice
|
||||
Automaton union = Automata.makeStringUnion(Arrays.asList(byteRefs)); // input must be sorted
|
||||
return new AutomatonQuery(new Term(fname), union);//constant scores
|
||||
}
|
||||
},
|
||||
|
|
|
@ -109,7 +109,7 @@ public class TestQueryTypes extends SolrTestCaseJ4 {
|
|||
);
|
||||
|
||||
String termsMethod = new String[]{"termsFilter", "booleanQuery", "automaton", "docValuesTermsFilter"}[random().nextInt(4)];
|
||||
assertQ(req( "q", "{!terms f=v_s method=" + termsMethod + " }other stuff,wow dude")
|
||||
assertQ(req( "q", "{!terms f=v_s method=" + termsMethod + " }wow dude,other stuff")//terms reverse sorted to show this works
|
||||
,"//result[@numFound='2']"
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue