reta opened a new pull request #749:
URL: https://github.com/apache/lucene/pull/749
# Description
IndexSortSortedNumericDocValuesRangeQuery unconditionally assumes the usage
of the LONG-encoded SortField. Using the numeric range query (in case of sorted
index) with anything but LONG ends up with class cast exception.
```
> java.lang.ClassCastException: class java.lang.Long cannot be cast to
class java.lang.Integer (java.lang.Long and java.lang.Integer are in module
java.base of loader 'bootstrap')
> at
org.apache.lucene.search.comparators.IntComparator.setTopValue(IntComparator.java:29)
> at
org.apache.lucene.sandbox.search.IndexSortSortedNumericDocValuesRangeQuery.loadComparator(IndexSortSortedNumericDocValuesRangeQuery.java:251)
> at
org.apache.lucene.sandbox.search.IndexSortSortedNumericDocValuesRangeQuery.getDocIdSetIterator(IndexSortSortedNumericDocValuesRangeQuery.java:206)
> at
org.apache.lucene.sandbox.search.IndexSortSortedNumericDocValuesRangeQuery$1.scorer(IndexSortSortedNumericDocValuesRangeQuery.java:170)
```
# Solution
The `IndexSortSortedNumericDocValuesRangeQuery` should consult the numeric
type of the `SortField` and perform appropriate conversions.
# Tests
Added the test cases for LONG / INT / FLOAT / DOUBLE fields.
# 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)
- [ ] 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]