mirror of https://github.com/apache/lucene.git
LUCENE-8196: Fix unordered case with non-matching subinterval
This commit is contained in:
parent
2265ec1947
commit
1a18acd783
|
@ -238,7 +238,9 @@ abstract class IntervalFunction {
|
|||
queueEnd = start = end = -1;
|
||||
this.queue.clear();
|
||||
for (IntervalIterator it : subIterators) {
|
||||
it.nextInterval();
|
||||
if (it.nextInterval() == NO_MORE_INTERVALS) {
|
||||
break;
|
||||
}
|
||||
queue.add(it);
|
||||
updateRightExtreme(it);
|
||||
}
|
||||
|
|
|
@ -166,4 +166,16 @@ public class TestIntervalQuery extends LuceneTestCase {
|
|||
checkHits(q, new int[]{ 6, 7 });
|
||||
}
|
||||
|
||||
public void testUnordered() throws IOException {
|
||||
Query q = new IntervalQuery(field,
|
||||
Intervals.unordered(
|
||||
Intervals.term("w1"),
|
||||
Intervals.ordered(
|
||||
Intervals.term("w3"),
|
||||
Intervals.term("yy")
|
||||
)
|
||||
)
|
||||
);
|
||||
checkHits(q, new int[]{3});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.lucene.search.intervals;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.CharArraySet;
|
||||
import org.apache.lucene.analysis.standard.StandardAnalyzer;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
|
@ -60,7 +61,7 @@ public class TestIntervals extends LuceneTestCase {
|
|||
|
||||
private static Directory directory;
|
||||
private static IndexSearcher searcher;
|
||||
private static Analyzer analyzer = new StandardAnalyzer();
|
||||
private static Analyzer analyzer = new StandardAnalyzer(CharArraySet.EMPTY_SET);
|
||||
|
||||
@BeforeClass
|
||||
public static void setupIndex() throws IOException {
|
||||
|
@ -172,7 +173,7 @@ public class TestIntervals extends LuceneTestCase {
|
|||
}
|
||||
|
||||
public void testIntervalDisjunction() throws IOException {
|
||||
checkIntervals(Intervals.or(Intervals.term("pease"), Intervals.term("hot")), "field1", 4, new int[][]{
|
||||
checkIntervals(Intervals.or(Intervals.term("pease"), Intervals.term("hot"), Intervals.term("notMatching")), "field1", 4, new int[][]{
|
||||
{},
|
||||
{ 0, 0, 2, 2, 3, 3, 6, 6, 17, 17},
|
||||
{ 0, 0, 3, 3, 5, 5, 6, 6, 21, 21},
|
||||
|
@ -194,4 +195,24 @@ public class TestIntervals extends LuceneTestCase {
|
|||
});
|
||||
}
|
||||
|
||||
public void testNesting2() throws IOException {
|
||||
checkIntervals(
|
||||
Intervals.unordered(
|
||||
Intervals.ordered(
|
||||
Intervals.term("like"),
|
||||
Intervals.term("it"),
|
||||
Intervals.term("cold")
|
||||
),
|
||||
Intervals.term("pease")
|
||||
),
|
||||
"field1", 2, new int[][]{
|
||||
{},
|
||||
{6, 21},
|
||||
{6, 17},
|
||||
{},
|
||||
{},
|
||||
{}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue