Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ordered intervals query and add test case #12214

Merged
merged 2 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ Bug Fixes

* GITHUB#12202: Fix MultiFieldQueryParser to apply boosts to regexp, wildcard, prefix, range, fuzzy queries. (Jasir KT)

* GITHUB#12214: Fix ordered intervals query to avoid skipping some of the results over interleaved terms. (Hongyu Yan)

Build
---------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public String toString() {

private static class OrderedIntervalIterator extends ConjunctionIntervalIterator {

int start = -1, end = -1, i;
int start = -1, end = -1, i = 1;
int slop;
final MatchCallback onMatch;

Expand All @@ -136,7 +136,6 @@ public int nextInterval() throws IOException {
start = end = slop = IntervalIterator.NO_MORE_INTERVALS;
int lastStart = Integer.MAX_VALUE;
boolean minimizing = false;
i = 1;
while (true) {
while (true) {
if (subIterators.get(i - 1).end() >= lastStart) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public void tearDown() throws Exception {
"greater new york",
"x x x x x intend x x x message x x x message x x x addressed x x",
"issue with intervals queries from search engine. So it's a big issue for us as we need to do ordered searches. Thank you to help us concerning that issue",
"場外好朋友"
"場外好朋友",
"alice bob alice alice carl alice bob alice carl"
};

private void checkHits(Query query, int[] results) throws IOException {
Expand Down Expand Up @@ -348,6 +349,17 @@ public void testOrderedWithGaps() throws IOException {
checkHits(q, new int[] {});
}

public void testOrderedWithGaps2() throws IOException {
Query q =
new IntervalQuery(
field,
Intervals.maxgaps(
1,
Intervals.ordered(
Intervals.term("alice"), Intervals.term("bob"), Intervals.term("carl"))));
checkHits(q, new int[] {12});
}

public void testNestedOrInContainedBy() throws IOException {
Query q =
new IntervalQuery(
Expand Down