khitrin opened a new pull request #270:
URL: https://github.com/apache/lucene/pull/270
# Description
Intervals matching iterator with wildcards and gaps for now throws NPE when
highlighting overlapping wildcard-based intervals.
Minimal reproducible example is highlighting "Compare Computer Science" by
`Intervals.maxgaps(1, Intervals.ordered(Intervals.wildcard(new
BytesRef("comp*")), Intervals.term("science")))`;
https://issues.apache.org/jira/browse/LUCENE-10075
# Solution
Proposed hotfix is weird, because it allows incorrect calls to
`DisjunctionMatchesIterator`, effectively breaking a contract from javadoc.
But, some implementations return Integer.MAX_VALUE instead of throwing an
exception, and at least `CachingMatchesIterator` relies on this behaviour (for
example, see `ConjunctionMatchesIterator.endPosition` code and
`IntervalIterator.end` javadoc).
I absolutely sure that altering logic in `CachingMatchesIterator` will be
the best solution for the issue, but I'm not very familiar with intervals and
cannot find yet a good fix for caching logic.
So I think about this PR as an only temporary hotfix that points an issue
and somewhat fixes it and I'm not sure that it worth to merge except the new
testcase.
# Tests
Added a new testc for interval highlighting based on example from issue.
# 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]