You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/12/07 01:33:01 UTC
[GitHub] [lucene] zhaih opened a new pull request #521: LUCENE-10229: Unify behaviour of match offsets for interval queries
zhaih opened a new pull request #521:
URL: https://github.com/apache/lucene/pull/521
https://issues.apache.org/jira/browse/LUCENE-10229
<!--
_(If you are a project committer then you may remove some/all of the following template.)_
Before creating a pull request, please file an issue in the ASF Jira system for Lucene:
* https://issues.apache.org/jira/projects/LUCENE
You will need to create an account in Jira in order to create an issue.
The title of the PR should reference the Jira issue number in the form:
* LUCENE-####: <short description of problem or changes>
LUCENE must be fully capitalized. A short description helps people scanning pull requests for items they can work on.
Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->
# Description
The problem is mostly that all the subclasses of `ConjunctionIntervalsSource` delegate the super class to handle for `matches` call and some of the subclasses need special care, for example `ContainedByIntervalsSource`. So this PR added a `createMatchesIterator` method for the subclasses to override the behavior.
However, there're still some behavior cannot be fixed easily, for example the "extend" operator, it is not obvious to me how to pull out the offsets for terms that are "extended"
# Tests
Copied most from the test that uncovers this discrepancy. Modified some old tests to accommodate the new behavior.
# Checklist
Please review the following and check all that apply:
- [x] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/lucene/HowToContribute) and my code conforms to the standards described there to the best of my ability.
- [x] I have created a Jira issue and added the issue ID to my pull request title.
- [x] I have given Lucene maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
- [x] I have developed this patch against the `main` branch.
- [x] I have run `./gradlew check`.
- [x] I have added tests for my changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] romseygeek commented on a change in pull request #521: LUCENE-10229: Unify behaviour of match offsets for interval queries
Posted by GitBox <gi...@apache.org>.
romseygeek commented on a change in pull request #521:
URL: https://github.com/apache/lucene/pull/521#discussion_r763805979
##########
File path: lucene/queries/src/java/org/apache/lucene/queries/intervals/Intervals.java
##########
@@ -275,7 +275,10 @@ public static IntervalsSource ordered(IntervalsSource... subSources) {
}
/**
- * Create an unordered {@link IntervalsSource}
+ * Create an unordered {@link IntervalsSource}. Note that if there are multiple intervals ends at
Review comment:
It happens sometimes! ;)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] dweiss merged pull request #521: LUCENE-10229: Unify behaviour of match offsets for interval queries
Posted by GitBox <gi...@apache.org>.
dweiss merged pull request #521:
URL: https://github.com/apache/lucene/pull/521
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] zhaih commented on a change in pull request #521: LUCENE-10229: Unify behaviour of match offsets for interval queries
Posted by GitBox <gi...@apache.org>.
zhaih commented on a change in pull request #521:
URL: https://github.com/apache/lucene/pull/521#discussion_r764251721
##########
File path: lucene/queries/src/java/org/apache/lucene/queries/intervals/Intervals.java
##########
@@ -275,7 +275,10 @@ public static IntervalsSource ordered(IntervalsSource... subSources) {
}
/**
- * Create an unordered {@link IntervalsSource}
+ * Create an unordered {@link IntervalsSource}. Note that if there are multiple intervals ends at
Review comment:
Makes sense!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] zhaih commented on pull request #521: LUCENE-10229: Unify behaviour of match offsets for interval queries
Posted by GitBox <gi...@apache.org>.
zhaih commented on pull request #521:
URL: https://github.com/apache/lucene/pull/521#issuecomment-988304204
@romseygeek Sure thing, I added one more test for the atLeast change
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] dweiss commented on pull request #521: LUCENE-10229: Unify behaviour of match offsets for interval queries
Posted by GitBox <gi...@apache.org>.
dweiss commented on pull request #521:
URL: https://github.com/apache/lucene/pull/521#issuecomment-990004272
Thank you @zhaih and apologies for the delay!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] zhaih commented on pull request #521: LUCENE-10229: Unify behaviour of match offsets for interval queries
Posted by GitBox <gi...@apache.org>.
zhaih commented on pull request #521:
URL: https://github.com/apache/lucene/pull/521#issuecomment-990171485
@dweiss NP and thank you for merging it!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] romseygeek commented on a change in pull request #521: LUCENE-10229: Unify behaviour of match offsets for interval queries
Posted by GitBox <gi...@apache.org>.
romseygeek commented on a change in pull request #521:
URL: https://github.com/apache/lucene/pull/521#discussion_r763792009
##########
File path: lucene/queries/src/java/org/apache/lucene/queries/intervals/Intervals.java
##########
@@ -275,7 +275,10 @@ public static IntervalsSource ordered(IntervalsSource... subSources) {
}
/**
- * Create an unordered {@link IntervalsSource}
+ * Create an unordered {@link IntervalsSource}. Note that if there are multiple intervals ends at
Review comment:
Intervals always resolve to their smallest possible span (the paper we based the implementation on refers to 'minimal interval semantics'). Otherwise you end up with a combinatorial explosion of possible matches.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] msokolov commented on a change in pull request #521: LUCENE-10229: Unify behaviour of match offsets for interval queries
Posted by GitBox <gi...@apache.org>.
msokolov commented on a change in pull request #521:
URL: https://github.com/apache/lucene/pull/521#discussion_r764555865
##########
File path: lucene/queries/src/java/org/apache/lucene/queries/intervals/Intervals.java
##########
@@ -275,7 +275,10 @@ public static IntervalsSource ordered(IntervalsSource... subSources) {
}
/**
- * Create an unordered {@link IntervalsSource}
+ * Create an unordered {@link IntervalsSource}. Note that if there are multiple intervals ends at
Review comment:
naive question here - if the intervals are supposed to be overlapping, how is it that the smaller "c d" survives to be considered? Oh I guess it does not -- there is no overlap found?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] msokolov commented on a change in pull request #521: LUCENE-10229: Unify behaviour of match offsets for interval queries
Posted by GitBox <gi...@apache.org>.
msokolov commented on a change in pull request #521:
URL: https://github.com/apache/lucene/pull/521#discussion_r764555865
##########
File path: lucene/queries/src/java/org/apache/lucene/queries/intervals/Intervals.java
##########
@@ -275,7 +275,10 @@ public static IntervalsSource ordered(IntervalsSource... subSources) {
}
/**
- * Create an unordered {@link IntervalsSource}
+ * Create an unordered {@link IntervalsSource}. Note that if there are multiple intervals ends at
Review comment:
naive question here - if the intervals are supposed to be overlapping, how is it that the smaller "c d" survives to be considered?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] zhaih commented on a change in pull request #521: LUCENE-10229: Unify behaviour of match offsets for interval queries
Posted by GitBox <gi...@apache.org>.
zhaih commented on a change in pull request #521:
URL: https://github.com/apache/lucene/pull/521#discussion_r763579212
##########
File path: lucene/queries/src/java/org/apache/lucene/queries/intervals/Intervals.java
##########
@@ -275,7 +275,10 @@ public static IntervalsSource ordered(IntervalsSource... subSources) {
}
/**
- * Create an unordered {@link IntervalsSource}
+ * Create an unordered {@link IntervalsSource}. Note that if there are multiple intervals ends at
Review comment:
I was surprised by this behavior, and maybe it will lead to some wrong result? Like if we have a query
```
overlapping(unordered("a","b"),unordered("c","d"))
```
and a doc
```
c a b c d
```
I think normally people would expect a match for the bigger "c...d" and "a b" in the middle? But in our implementation it won't give any match...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] dweiss commented on a change in pull request #521: LUCENE-10229: Unify behaviour of match offsets for interval queries
Posted by GitBox <gi...@apache.org>.
dweiss commented on a change in pull request #521:
URL: https://github.com/apache/lucene/pull/521#discussion_r763712209
##########
File path: lucene/highlighter/src/test/org/apache/lucene/search/matchhighlight/TestMatchRegionRetriever.java
##########
@@ -379,17 +379,17 @@ public void testIntervalQueries() throws Exception {
Intervals.containedBy(
Intervals.term("foo"),
Intervals.unordered(Intervals.term("foo"), Intervals.term("bar"))))),
- containsInAnyOrder(fmt("2: (field_text_offs: '>bar baz foo< xyz')", field)));
Review comment:
Oh, awesome that this is fixed too.
##########
File path: lucene/highlighter/src/test/org/apache/lucene/search/matchhighlight/TestMatchHighlighter.java
##########
@@ -541,6 +539,234 @@ protected TokenStreamComponents createComponents(String fieldName) {
});
}
+ /**
+ * Almost the same as the one above, make sure the fields indexed with offsets are also
+ * highlighted correctly
+ */
+ @Test
+ public void testIntervalFunctionsWithOffsetField() throws Exception {
+ Analyzer analyzer =
+ new Analyzer() {
+ @Override
+ protected TokenStreamComponents createComponents(String fieldName) {
+ Tokenizer tokenizer = new StandardTokenizer();
+ TokenStream ts = tokenizer;
+ ts = new LowerCaseFilter(ts);
+ return new TokenStreamComponents(tokenizer, ts);
+ }
+ };
+
+ String field = FLD_TEXT1;
+ new IndexBuilder(this::toField)
+ // Just one document and multiple interval queries.
+ .doc(field, "The quick brown fox jumps over the lazy dog")
+ .build(
+ analyzer,
+ reader -> {
+ IndexSearcher searcher = new IndexSearcher(reader);
+ Sort sortOrder = Sort.INDEXORDER; // So that results are consistently ordered.
+
+ MatchHighlighter highlighter =
+ new MatchHighlighter(searcher, analyzer)
+ .appendFieldHighlighter(
+ FieldValueHighlighters.highlighted(
+ 80 * 3, 1, new PassageFormatter("...", ">", "<"), fld -> true))
+ .appendFieldHighlighter(FieldValueHighlighters.skipRemaining());
+
+ StandardQueryParser qp = new StandardQueryParser(analyzer);
+
+ // Run all pairs of query-expected highlight.
+ List<String> errors = new ArrayList<>();
+ for (var queryHighlightPair :
+ new String[][] {
+ {
+ "fn:ordered(brown dog)",
+ "0. %s: The quick >brown fox jumps over the lazy dog<"
+ },
+ {
+ "fn:within(fn:or(lazy quick) 1 fn:or(dog fox))",
+ "0. %s: The quick brown fox jumps over the >lazy< dog"
+ },
+ {
+ "fn:containedBy(fox fn:ordered(brown fox dog))",
+ "0. %s: The quick brown >fox< jumps over the lazy dog"
+ },
+ {
+ "fn:atLeast(2 quick fox \"furry dog\")",
+ "0. %s: The >quick brown fox< jumps over the lazy dog"
+ },
+ {
+ "fn:maxgaps(0 fn:ordered(fn:or(quick lazy) fn:or(fox dog)))",
+ "0. %s: The quick brown fox jumps over the >lazy dog<"
+ },
+ {
+ "fn:maxgaps(1 fn:ordered(fn:or(quick lazy) fn:or(fox dog)))",
+ "0. %s: The >quick brown fox< jumps over the >lazy dog<"
+ },
+ {
+ "fn:maxwidth(2 fn:ordered(fn:or(quick lazy) fn:or(fox dog)))",
+ "0. %s: The quick brown fox jumps over the >lazy dog<"
+ },
+ {
+ "fn:maxwidth(3 fn:ordered(fn:or(quick lazy) fn:or(fox dog)))",
+ "0. %s: The >quick brown fox< jumps over the >lazy dog<"
+ },
+ {
+ "fn:or(quick \"fox\")",
+ "0. %s: The >quick< brown >fox< jumps over the lazy dog"
+ },
+ {"fn:or(\"quick fox\")"},
+ {
+ "fn:phrase(quick brown fox)",
+ "0. %s: The >quick brown fox< jumps over the lazy dog"
+ },
+ {"fn:wildcard(jump*)", "0. %s: The quick brown fox >jumps< over the lazy dog"},
+ {"fn:wildcard(br*n)", "0. %s: The quick >brown< fox jumps over the lazy dog"},
+ {"fn:or(dog fox)", "0. %s: The quick brown >fox< jumps over the lazy >dog<"},
+ {
+ "fn:phrase(fn:ordered(quick fox) jumps)",
+ "0. %s: The >quick brown fox jumps< over the lazy dog"
+ },
+ {
+ "fn:ordered(quick jumps dog)",
+ "0. %s: The >quick brown fox jumps over the lazy dog<"
+ },
+ {
+ "fn:ordered(quick fn:or(fox dog))",
+ "0. %s: The >quick brown fox< jumps over the lazy dog"
+ },
+ {
+ "fn:ordered(quick jumps fn:or(fox dog))",
+ "0. %s: The >quick brown fox jumps over the lazy dog<"
+ },
+ {
+ "fn:unordered(dog jumps quick)",
+ "0. %s: The >quick brown fox jumps over the lazy dog<"
+ },
+ {
+ "fn:unordered(fn:or(fox dog) quick)",
+ "0. %s: The >quick brown fox< jumps over the lazy dog"
+ },
+ {
+ "fn:unordered(fn:phrase(brown fox) fn:phrase(fox jumps))",
+ "0. %s: The quick >brown fox jumps< over the lazy dog"
+ },
+ {"fn:ordered(fn:phrase(brown fox) fn:phrase(fox jumps))"},
+ {"fn:unorderedNoOverlaps(fn:phrase(brown fox) fn:phrase(fox jumps))"},
+ {
+ "fn:before(fn:or(brown lazy) fox)",
+ "0. %s: The quick >brown< fox jumps over the lazy dog"
+ },
+ {
+ "fn:before(fn:or(brown lazy) fn:or(dog fox))",
+ "0. %s: The quick >brown< fox jumps over the >lazy< dog"
+ },
+ {
+ "fn:after(fn:or(brown lazy) fox)",
+ "0. %s: The quick brown fox jumps over the >lazy< dog"
+ },
+ {
+ "fn:after(fn:or(brown lazy) fn:or(dog fox))",
+ "0. %s: The quick brown fox jumps over the >lazy< dog"
+ },
+ {
+ "fn:within(fn:or(fox dog) 1 fn:or(quick lazy))",
+ "0. %s: The quick brown fox jumps over the lazy >dog<"
+ },
+ {
+ "fn:within(fn:or(fox dog) 2 fn:or(quick lazy))",
+ "0. %s: The quick brown >fox< jumps over the lazy >dog<"
+ },
+ {
+ "fn:notWithin(fn:or(fox dog) 1 fn:or(quick lazy))",
+ "0. %s: The quick brown >fox< jumps over the lazy dog"
+ },
+ {
+ "fn:containedBy(fn:or(fox dog) fn:ordered(quick lazy))",
+ "0. %s: The quick brown >fox< jumps over the lazy dog"
+ },
+ {
+ "fn:notContainedBy(fn:or(fox dog) fn:ordered(quick lazy))",
+ "0. %s: The quick brown fox jumps over the lazy >dog<"
+ },
+ {
+ "fn:containing(fn:atLeast(2 quick fox dog) jumps)",
+ "0. %s: The quick brown >fox jumps over the lazy dog<"
+ },
+ {
+ "fn:notContaining(fn:ordered(fn:or(the The) fn:or(fox dog)) brown)",
+ "0. %s: The quick brown fox jumps over >the lazy dog<"
+ },
+ {
+ "fn:overlapping(fn:phrase(brown fox) fn:phrase(fox jumps))",
+ "0. %s: The quick >brown fox< jumps over the lazy dog"
+ },
+ {
+ "fn:overlapping(fn:or(fox dog) fn:extend(lazy 2 2))",
+ "0. %s: The quick brown fox jumps over the lazy >dog<"
+ },
+ {
+ "fn:nonOverlapping(fn:phrase(brown fox) fn:phrase(lazy dog))",
+ "0. %s: The quick >brown fox< jumps over the lazy dog"
+ },
+ {
+ "fn:nonOverlapping(fn:or(fox dog) fn:extend(lazy 2 2))",
+ "0. %s: The quick brown >fox< jumps over the lazy dog"
+ },
+ {
+ "fn:atLeast(2 fn:unordered(furry dog) fn:unordered(brown dog) lazy quick)",
+ "0. %s: The >quick >brown fox jumps over the lazy<<> dog<"
+ },
+ /*
+ The test cases below does not work for fields enabled with offset yet:
Review comment:
Add a todo, maybe? Also: "do not work" (plural).
##########
File path: lucene/queries/src/java/org/apache/lucene/queries/intervals/Intervals.java
##########
@@ -275,7 +275,10 @@ public static IntervalsSource ordered(IntervalsSource... subSources) {
}
/**
- * Create an unordered {@link IntervalsSource}
+ * Create an unordered {@link IntervalsSource}. Note that if there are multiple intervals ends at
Review comment:
It does look like a bug - all c..d alternatives should be considered here, @romseygeek ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] zhaih commented on a change in pull request #521: LUCENE-10229: Unify behaviour of match offsets for interval queries
Posted by GitBox <gi...@apache.org>.
zhaih commented on a change in pull request #521:
URL: https://github.com/apache/lucene/pull/521#discussion_r763577418
##########
File path: lucene/queries/src/java/org/apache/lucene/queries/intervals/MinimumShouldMatchIntervalsSource.java
##########
@@ -215,6 +215,7 @@ public int gaps() {
@Override
public int nextInterval() throws IOException {
+ lead = null;
Review comment:
This is necessary, since if we returned on L243, the lead will remain to be the lead of the previous interval. This fixes this case:
```
{
"fn:atLeast(2 fn:unordered(furry dog) fn:unordered(brown dog) lazy quick)",
"0. %s: The >quick >brown fox jumps over the lazy<<> dog<"
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] dweiss commented on a change in pull request #521: LUCENE-10229: Unify behaviour of match offsets for interval queries
Posted by GitBox <gi...@apache.org>.
dweiss commented on a change in pull request #521:
URL: https://github.com/apache/lucene/pull/521#discussion_r763795223
##########
File path: lucene/queries/src/java/org/apache/lucene/queries/intervals/Intervals.java
##########
@@ -275,7 +275,10 @@ public static IntervalsSource ordered(IntervalsSource... subSources) {
}
/**
- * Create an unordered {@link IntervalsSource}
+ * Create an unordered {@link IntervalsSource}. Note that if there are multiple intervals ends at
Review comment:
You're right!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] zhaih commented on a change in pull request #521: LUCENE-10229: Unify behaviour of match offsets for interval queries
Posted by GitBox <gi...@apache.org>.
zhaih commented on a change in pull request #521:
URL: https://github.com/apache/lucene/pull/521#discussion_r764406016
##########
File path: lucene/highlighter/src/test/org/apache/lucene/search/matchhighlight/TestMatchHighlighter.java
##########
@@ -541,6 +539,234 @@ protected TokenStreamComponents createComponents(String fieldName) {
});
}
+ /**
+ * Almost the same as the one above, make sure the fields indexed with offsets are also
+ * highlighted correctly
+ */
+ @Test
+ public void testIntervalFunctionsWithOffsetField() throws Exception {
+ Analyzer analyzer =
+ new Analyzer() {
+ @Override
+ protected TokenStreamComponents createComponents(String fieldName) {
+ Tokenizer tokenizer = new StandardTokenizer();
+ TokenStream ts = tokenizer;
+ ts = new LowerCaseFilter(ts);
+ return new TokenStreamComponents(tokenizer, ts);
+ }
+ };
+
+ String field = FLD_TEXT1;
+ new IndexBuilder(this::toField)
+ // Just one document and multiple interval queries.
+ .doc(field, "The quick brown fox jumps over the lazy dog")
+ .build(
+ analyzer,
+ reader -> {
+ IndexSearcher searcher = new IndexSearcher(reader);
+ Sort sortOrder = Sort.INDEXORDER; // So that results are consistently ordered.
+
+ MatchHighlighter highlighter =
+ new MatchHighlighter(searcher, analyzer)
+ .appendFieldHighlighter(
+ FieldValueHighlighters.highlighted(
+ 80 * 3, 1, new PassageFormatter("...", ">", "<"), fld -> true))
+ .appendFieldHighlighter(FieldValueHighlighters.skipRemaining());
+
+ StandardQueryParser qp = new StandardQueryParser(analyzer);
+
+ // Run all pairs of query-expected highlight.
+ List<String> errors = new ArrayList<>();
+ for (var queryHighlightPair :
+ new String[][] {
+ {
+ "fn:ordered(brown dog)",
+ "0. %s: The quick >brown fox jumps over the lazy dog<"
+ },
+ {
+ "fn:within(fn:or(lazy quick) 1 fn:or(dog fox))",
+ "0. %s: The quick brown fox jumps over the >lazy< dog"
+ },
+ {
+ "fn:containedBy(fox fn:ordered(brown fox dog))",
+ "0. %s: The quick brown >fox< jumps over the lazy dog"
+ },
+ {
+ "fn:atLeast(2 quick fox \"furry dog\")",
+ "0. %s: The >quick brown fox< jumps over the lazy dog"
+ },
+ {
+ "fn:maxgaps(0 fn:ordered(fn:or(quick lazy) fn:or(fox dog)))",
+ "0. %s: The quick brown fox jumps over the >lazy dog<"
+ },
+ {
+ "fn:maxgaps(1 fn:ordered(fn:or(quick lazy) fn:or(fox dog)))",
+ "0. %s: The >quick brown fox< jumps over the >lazy dog<"
+ },
+ {
+ "fn:maxwidth(2 fn:ordered(fn:or(quick lazy) fn:or(fox dog)))",
+ "0. %s: The quick brown fox jumps over the >lazy dog<"
+ },
+ {
+ "fn:maxwidth(3 fn:ordered(fn:or(quick lazy) fn:or(fox dog)))",
+ "0. %s: The >quick brown fox< jumps over the >lazy dog<"
+ },
+ {
+ "fn:or(quick \"fox\")",
+ "0. %s: The >quick< brown >fox< jumps over the lazy dog"
+ },
+ {"fn:or(\"quick fox\")"},
+ {
+ "fn:phrase(quick brown fox)",
+ "0. %s: The >quick brown fox< jumps over the lazy dog"
+ },
+ {"fn:wildcard(jump*)", "0. %s: The quick brown fox >jumps< over the lazy dog"},
+ {"fn:wildcard(br*n)", "0. %s: The quick >brown< fox jumps over the lazy dog"},
+ {"fn:or(dog fox)", "0. %s: The quick brown >fox< jumps over the lazy >dog<"},
+ {
+ "fn:phrase(fn:ordered(quick fox) jumps)",
+ "0. %s: The >quick brown fox jumps< over the lazy dog"
+ },
+ {
+ "fn:ordered(quick jumps dog)",
+ "0. %s: The >quick brown fox jumps over the lazy dog<"
+ },
+ {
+ "fn:ordered(quick fn:or(fox dog))",
+ "0. %s: The >quick brown fox< jumps over the lazy dog"
+ },
+ {
+ "fn:ordered(quick jumps fn:or(fox dog))",
+ "0. %s: The >quick brown fox jumps over the lazy dog<"
+ },
+ {
+ "fn:unordered(dog jumps quick)",
+ "0. %s: The >quick brown fox jumps over the lazy dog<"
+ },
+ {
+ "fn:unordered(fn:or(fox dog) quick)",
+ "0. %s: The >quick brown fox< jumps over the lazy dog"
+ },
+ {
+ "fn:unordered(fn:phrase(brown fox) fn:phrase(fox jumps))",
+ "0. %s: The quick >brown fox jumps< over the lazy dog"
+ },
+ {"fn:ordered(fn:phrase(brown fox) fn:phrase(fox jumps))"},
+ {"fn:unorderedNoOverlaps(fn:phrase(brown fox) fn:phrase(fox jumps))"},
+ {
+ "fn:before(fn:or(brown lazy) fox)",
+ "0. %s: The quick >brown< fox jumps over the lazy dog"
+ },
+ {
+ "fn:before(fn:or(brown lazy) fn:or(dog fox))",
+ "0. %s: The quick >brown< fox jumps over the >lazy< dog"
+ },
+ {
+ "fn:after(fn:or(brown lazy) fox)",
+ "0. %s: The quick brown fox jumps over the >lazy< dog"
+ },
+ {
+ "fn:after(fn:or(brown lazy) fn:or(dog fox))",
+ "0. %s: The quick brown fox jumps over the >lazy< dog"
+ },
+ {
+ "fn:within(fn:or(fox dog) 1 fn:or(quick lazy))",
+ "0. %s: The quick brown fox jumps over the lazy >dog<"
+ },
+ {
+ "fn:within(fn:or(fox dog) 2 fn:or(quick lazy))",
+ "0. %s: The quick brown >fox< jumps over the lazy >dog<"
+ },
+ {
+ "fn:notWithin(fn:or(fox dog) 1 fn:or(quick lazy))",
+ "0. %s: The quick brown >fox< jumps over the lazy dog"
+ },
+ {
+ "fn:containedBy(fn:or(fox dog) fn:ordered(quick lazy))",
+ "0. %s: The quick brown >fox< jumps over the lazy dog"
+ },
+ {
+ "fn:notContainedBy(fn:or(fox dog) fn:ordered(quick lazy))",
+ "0. %s: The quick brown fox jumps over the lazy >dog<"
+ },
+ {
+ "fn:containing(fn:atLeast(2 quick fox dog) jumps)",
+ "0. %s: The quick brown >fox jumps over the lazy dog<"
+ },
+ {
+ "fn:notContaining(fn:ordered(fn:or(the The) fn:or(fox dog)) brown)",
+ "0. %s: The quick brown fox jumps over >the lazy dog<"
+ },
+ {
+ "fn:overlapping(fn:phrase(brown fox) fn:phrase(fox jumps))",
+ "0. %s: The quick >brown fox< jumps over the lazy dog"
+ },
+ {
+ "fn:overlapping(fn:or(fox dog) fn:extend(lazy 2 2))",
+ "0. %s: The quick brown fox jumps over the lazy >dog<"
+ },
+ {
+ "fn:nonOverlapping(fn:phrase(brown fox) fn:phrase(lazy dog))",
+ "0. %s: The quick >brown fox< jumps over the lazy dog"
+ },
+ {
+ "fn:nonOverlapping(fn:or(fox dog) fn:extend(lazy 2 2))",
+ "0. %s: The quick brown >fox< jumps over the lazy dog"
+ },
+ {
+ "fn:atLeast(2 fn:unordered(furry dog) fn:unordered(brown dog) lazy quick)",
+ "0. %s: The >quick >brown fox jumps over the lazy<<> dog<"
+ },
+ /*
+ The test cases below does not work for fields enabled with offset yet:
Review comment:
Done!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] romseygeek commented on pull request #521: LUCENE-10229: Unify behaviour of match offsets for interval queries
Posted by GitBox <gi...@apache.org>.
romseygeek commented on pull request #521:
URL: https://github.com/apache/lucene/pull/521#issuecomment-987729638
This looks great, thanks @zhaih!
Could we also add a test for the atLeast case in TestIntervals? Testing in highlighting is great, but I'd like to make sure we cover as much as possible within the intervals tests themselves as it makes it easier for future development.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] dweiss commented on a change in pull request #521: LUCENE-10229: Unify behaviour of match offsets for interval queries
Posted by GitBox <gi...@apache.org>.
dweiss commented on a change in pull request #521:
URL: https://github.com/apache/lucene/pull/521#discussion_r764938074
##########
File path: lucene/queries/src/java/org/apache/lucene/queries/intervals/Intervals.java
##########
@@ -275,7 +275,10 @@ public static IntervalsSource ordered(IntervalsSource... subSources) {
}
/**
- * Create an unordered {@link IntervalsSource}
+ * Create an unordered {@link IntervalsSource}. Note that if there are multiple intervals ends at
Review comment:
There is no overlap indeed - one interval is 'a b' the other 'c d' (the smallest possible variant). This is tricky - I agree -- but does not negate the utility of the entire concept.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org