SOLR-15437: ReRanking / LTR does not work in SolrCloud with custom sort by score
https://issues.apache.org/jira/browse/SOLR-15437
Description
This Pr is based upon the changes made in https://github.com/apache/solr/pull/151. So the base for this PR is a functioning ReRank / LTR in SolrCloud. The problem that this PR wants to solve is, that the not-reRanked documents cannot be sorted by score.
The cause for this is, that the originalScore of a document gets overridden during ReRanking. Therefore we cannot access it if the document should no longer be reRanked after merging the results of multiple shards. (Because its reRanked score is too low for it to be placed under the number of documents that should be reRanked.)
Solution
Please note: The code in this PR is a very rough draft. There are multiple FIXMEs and TODOs that still need to addressed. Also, I am not sure about the multisharding bahavior. This is why this PR is a draft. It should serve as base to enable a better exchange about possible solutions.
We track the originalScore similar to the score. The originalScore never gets overridden. We can use it for the queue in the SortedHitQueueManager.
(More detail will follow.)
Tests
We made the test testSimpleQueryCustomSortByScoreWithSubResultSetAndRowsLessThanExistingDocs that checks that the documents that should not get reRanked are sorted by score.
Multiple tests break!
The tests in org.apache.solr.ltr are green with changes in TestLTRReRankingPipeline.testDocParam().
Tests in org.apache.solr:
4115 tests run (I cancelled it)
3971 passes
seed: seed#[3DC97B489377F7B9]
tests failes 2:
- org.apache.solr.handler.component.DistributedQueryComponentReRankTest
- org.apache.solr.search.MergeStrategyTest
Checklist
Please review the following and check all that apply:
- [X] I have reviewed the guidelines for How to Contribute 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 Solr maintainers access to contribute to my PR branch. (optional but recommended)
- [ ] I have developed this patch against the
mainbranch. Attention! No, this is developed against the branch from https://github.com/apache/solr/pull/151 - [ ] I have run
./gradlew check. - [ ] I have added tests for my changes.
- [ ] I have added documentation for the Reference Guide