Add pagination / document limit logic for reranking - #32
Merged
Conversation
…than the default 10. * Add preprocess request interface to ResultTransformer * Override from and size parameters durig preprocess, to fetch more hits from OpenSearch * Limit the number of documents sent to Kendra Ranking (Will make this number configurable in a follow up) * Populate response documents from re-ranked hits (upto Kendra limit) and OpenSearch hits beyond the limit Signed-off-by: Mahita Mahesh <mahitam@amazon.com> Signed-off-by: Michael Froh <froh@amazon.com>
Signed-off-by: Mahita Mahesh <mahitam@amazon.com>
Signed-off-by: Mahita Mahesh <mahitam@amazon.com> Signed-off-by: Michael Froh <froh@amazon.com>
Add unit tests for the pagination logic in SearchActionFilter as well as the whole KendraIntelligentRanker class (including pagination). Also, removed OriginalRequestFields in favor of cloning the SearchSourceBuilder. Signed-off-by: Michael Froh <froh@amazon.com>
Updating integration test to match approach used by other recent plugins, in the hope of fixing test runs on Windows. Signed-off-by: Michael Froh <froh@amazon.com>
| // Unknown query type or query does not reference body field | ||
| return hits; | ||
| } | ||
| if (hits.getHits().length == 0) { |
Contributor
There was a problem hiding this comment.
Nit: If we check this right up front, we can avoid the query parser step too
Collaborator
Author
There was a problem hiding this comment.
Good catch, thanks!
|
|
||
| public void testShouldNotTransformWithoutQuery() { | ||
| KendraIntelligentRanker ranker = new KendraIntelligentRanker(buildMockHttpClient()); | ||
| SearchRequest originalRequest = new SearchRequest(); |
Contributor
There was a problem hiding this comment.
We should set the SearchSourceBuilder with query(null) here
Collaborator
Author
There was a problem hiding this comment.
Oops! Thanks
I think I copy/pasted the test above, got distracted, then came back and started writing the next test. 😁
* Fix test case with non-null source but null query. * Skip transform on empty results before doing any work. Signed-off-by: Michael Froh <froh@amazon.com>
mahitamahesh
approved these changes
Nov 23, 2022
* Earlier test covered empty hits, so we should assume that Kendra ranking handles at least 1 hit. Signed-off-by: Michael Froh <froh@amazon.com>
Collaborator
Author
|
Yay for randomized testing! My earlier commit failed on the case where Still, it's nice to know that we're considering many possibilities. |
macohen
approved these changes
Nov 23, 2022
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This change augments opensearch-project/search-relevance#26 by adding unit tests.
preprocessRequestinterface to ResultTransformer.fromandsizeparameters during preprocess, to fetch more than the default 10 hits from OpenSearch (improved accuracy if the ranker can access more documents)Issues Resolved
N/A
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.