-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Pinned retriever #126401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pinned retriever #126401
Conversation
Hi @mridula-s109, I've created a changelog YAML for you. |
Pinging @elastic/search-eng (Team:SearchOrg) |
Pinging @elastic/search-relevance (Team:Search - Relevance) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick pass through, I'm surprised this works without registering the retriever?
...es/src/yamlRestTest/resources/rest-api-spec/test/searchbusinessrules/10_pinned_retriever.yml
Outdated
Show resolved
Hide resolved
Pull request was converted to draft
f162bac
to
9bc751a
Compare
Hi @mridula-s109, I've created a changelog YAML for you. |
* Fix compilation error * Remove SearchPlugin from META-INF * Remove duplicate FeatureSpecification * Add service as test resource * Move to test * More file moving * Remove from module-info, remove file * Make search business rules plugin extensible * fix ent search plugin * Delete dup files * [CI] Auto commit changes from spotless * Add module info back in --------- Co-authored-by: elasticsearchmachine <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some hopefully final feedback! Thanks for your iterations on this.
As a best practice it would be good to request review from the Search Relevance team so everyone on the team is aware of this PR.
Awaiting CI and final changes but this is really close!
...plugin/rank-rrf/src/yamlRestTest/resources/rest-api-spec/test/rrf/950_pinned_interaction.yml
Show resolved
Hide resolved
...ess-rules/src/main/java/org/elasticsearch/xpack/searchbusinessrules/SearchBusinessRules.java
Outdated
Show resolved
Hide resolved
.../main/java/org/elasticsearch/xpack/searchbusinessrules/retriever/PinnedRetrieverBuilder.java
Outdated
Show resolved
Hide resolved
.../main/java/org/elasticsearch/xpack/searchbusinessrules/retriever/PinnedRetrieverBuilder.java
Outdated
Show resolved
Hide resolved
.../src/yamlRestTest/resources/rest-api-spec/test/search-business-rules/10_pinned_retriever.yml
Outdated
Show resolved
Hide resolved
.../src/yamlRestTest/resources/rest-api-spec/test/search-business-rules/10_pinned_retriever.yml
Outdated
Show resolved
Hide resolved
.../src/yamlRestTest/resources/rest-api-spec/test/search-business-rules/10_pinned_retriever.yml
Outdated
Show resolved
Hide resolved
.../src/yamlRestTest/resources/rest-api-spec/test/search-business-rules/10_pinned_retriever.yml
Outdated
Show resolved
Hide resolved
.../src/yamlRestTest/resources/rest-api-spec/test/search-business-rules/10_pinned_retriever.yml
Outdated
Show resolved
Hide resolved
.../src/yamlRestTest/resources/rest-api-spec/test/search-business-rules/10_pinned_retriever.yml
Show resolved
Hide resolved
d1e4be8
to
e86c6e0
Compare
…, as i had made changes related to the cluster error
I have resolved all the comments @kderusso , hopefully the ci build passes through and everything works as intended. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I tested it locally.
Checked the comments from @kderusso from the last review and it looks to me that all have been addressed.
@@ -231,6 +231,7 @@ static TransportVersion def(int id) { | |||
public static final TransportVersion INTRODUCE_FAILURES_LIFECYCLE = def(9_065_0_00); | |||
public static final TransportVersion PROJECT_METADATA_SETTINGS = def(9_066_00_0); | |||
public static final TransportVersion AGGREGATE_METRIC_DOUBLE_BLOCK = def(9_067_00_0); | |||
public static final TransportVersion PINNED_RETRIEVER = def(9_068_0_00); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a side note - but when we backport this to 8.19, we need to pay extra attention on how we backport this transport version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah @mridula-s109 - we will create a PINNED_RETRIEVER_8_19
transport version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks for all the iterations!
@@ -231,6 +231,7 @@ static TransportVersion def(int id) { | |||
public static final TransportVersion INTRODUCE_FAILURES_LIFECYCLE = def(9_065_0_00); | |||
public static final TransportVersion PROJECT_METADATA_SETTINGS = def(9_066_00_0); | |||
public static final TransportVersion AGGREGATE_METRIC_DOUBLE_BLOCK = def(9_067_00_0); | |||
public static final TransportVersion PINNED_RETRIEVER = def(9_068_0_00); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah @mridula-s109 - we will create a PINNED_RETRIEVER_8_19
transport version
💔 Backport failed
You can use sqren/backport to manually backport by running |
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
* Created PinnedQueryRetriever Builder * Added retriever build test file * Changed the test to accept all the retrievers as its not licensed * [CI] Auto commit changes from spotless * Added integration test and fixed the code style issues * Fixed merge issues * Added cluster test feature to the integration tests * Update docs/changelog/126401.yaml * Registered retriever plugin * Enhanced changelog description * Added validation to the constructor creation * Introduced validations in the code and incorporated in tests - compiling version * Included PinnedRankDoc to enhance the explain query, validations for inputs anfd sorting. Fixed the tests after these changes * Working on improving integration test and introducing cluster features * Removed cluster test temporarily * Got pinnedretriever yaml to working state without cluster * [CI] Auto commit changes from spotless * Resolved no source yaml error * Cluster loaded successfully * [CI] Auto commit changes from spotless * Fixed integration test * Made validate sort less strict * Included shareddoc sorting in the validate sort * All yaml issues resolved * Explanation yaml files added * Trying to add clustering to the test * [CI] Auto commit changes from spotless * Removed explicit feature specification * Deleted the empty file * Put the node feature in the proper place * Added additional validation in ids and docs * Cleaned the create pinned query validation * made unit tests robust * Remove query.es from version control * Remove result.json from version control * [CI] Auto commit changes from spotless * Everything except explanation is fixed * added duplicate doc test * Applied checkstyle fix, spotless and a failing yaml * Improvements based on PR comments * [CI] Auto commit changes from spotless * Modified the unit test to accomodate the change in createPinnedQuery * Split the yaml to test for basic and trial, cleanedup and acted on all the comments * Remove result.json and query.es from version control * Removed unnecessary comments * Removed redundant file * Fixing CI build error * [CI] Auto commit changes from spotless * Removed pinnedBy as it wasnt necessary * Removed unnecessary ToXContent Information * Fixed transport version charges and cleaned up null checks: " * [CI] Auto commit changes from spotless * Retriever status changed to 9.1 version * cleaned up 2 yamltestsuite for different licenses * Trying to get the clustering works * Cleaned up the yaml clustering and also reorganised the yaml tests * Unnecessary file introduction removed * Reverted the plugins to the previous state as the changes werent necessary * Removed unnecessary transport versioning from pinnedrankdoc * reverted * [CI] Auto commit changes from spotless * Edited the SearchBusinessRules to remove the class from getFeatures * [CI] Auto commit changes from spotless * Cleaned up Pinned retriever to allow only id or docs * Added more test to the pinned retriever * did spotless * Introduced new transport versioning * Cleaning it up * Resolved validate module error * BWT issues * [CI] Auto commit changes from spotless * fix NPE occuring in ci * trying to fix duplicate feature issue * [CI] Auto commit changes from spotless * modified the tests * Playing with pinned retriever CI (elastic#127530) * Fix compilation error * Remove SearchPlugin from META-INF * Remove duplicate FeatureSpecification * Add service as test resource * Move to test * More file moving * Remove from module-info, remove file * Make search business rules plugin extensible * fix ent search plugin * Delete dup files * [CI] Auto commit changes from spotless * Add module info back in --------- Co-authored-by: elasticsearchmachine <[email protected]> * top document no pinned * Removing this to see if it works without this transport version check, as i had made changes related to the cluster error * Fixed the retriever builder comments and error message * removed the unnencessary explain * Fixed all the tests in the yaml file * added extra test case * [CI] Auto commit changes from spotless --------- Co-authored-by: elasticsearchmachine <[email protected]> Co-authored-by: Kathleen DeRusso <[email protected]> (cherry picked from commit b742b02) # Conflicts: # server/src/main/java/org/elasticsearch/TransportVersions.java
* Pinned retriever (#126401) * Created PinnedQueryRetriever Builder * Added retriever build test file * Changed the test to accept all the retrievers as its not licensed * [CI] Auto commit changes from spotless * Added integration test and fixed the code style issues * Fixed merge issues * Added cluster test feature to the integration tests * Update docs/changelog/126401.yaml * Registered retriever plugin * Enhanced changelog description * Added validation to the constructor creation * Introduced validations in the code and incorporated in tests - compiling version * Included PinnedRankDoc to enhance the explain query, validations for inputs anfd sorting. Fixed the tests after these changes * Working on improving integration test and introducing cluster features * Removed cluster test temporarily * Got pinnedretriever yaml to working state without cluster * [CI] Auto commit changes from spotless * Resolved no source yaml error * Cluster loaded successfully * [CI] Auto commit changes from spotless * Fixed integration test * Made validate sort less strict * Included shareddoc sorting in the validate sort * All yaml issues resolved * Explanation yaml files added * Trying to add clustering to the test * [CI] Auto commit changes from spotless * Removed explicit feature specification * Deleted the empty file * Put the node feature in the proper place * Added additional validation in ids and docs * Cleaned the create pinned query validation * made unit tests robust * Remove query.es from version control * Remove result.json from version control * [CI] Auto commit changes from spotless * Everything except explanation is fixed * added duplicate doc test * Applied checkstyle fix, spotless and a failing yaml * Improvements based on PR comments * [CI] Auto commit changes from spotless * Modified the unit test to accomodate the change in createPinnedQuery * Split the yaml to test for basic and trial, cleanedup and acted on all the comments * Remove result.json and query.es from version control * Removed unnecessary comments * Removed redundant file * Fixing CI build error * [CI] Auto commit changes from spotless * Removed pinnedBy as it wasnt necessary * Removed unnecessary ToXContent Information * Fixed transport version charges and cleaned up null checks: " * [CI] Auto commit changes from spotless * Retriever status changed to 9.1 version * cleaned up 2 yamltestsuite for different licenses * Trying to get the clustering works * Cleaned up the yaml clustering and also reorganised the yaml tests * Unnecessary file introduction removed * Reverted the plugins to the previous state as the changes werent necessary * Removed unnecessary transport versioning from pinnedrankdoc * reverted * [CI] Auto commit changes from spotless * Edited the SearchBusinessRules to remove the class from getFeatures * [CI] Auto commit changes from spotless * Cleaned up Pinned retriever to allow only id or docs * Added more test to the pinned retriever * did spotless * Introduced new transport versioning * Cleaning it up * Resolved validate module error * BWT issues * [CI] Auto commit changes from spotless * fix NPE occuring in ci * trying to fix duplicate feature issue * [CI] Auto commit changes from spotless * modified the tests * Playing with pinned retriever CI (#127530) * Fix compilation error * Remove SearchPlugin from META-INF * Remove duplicate FeatureSpecification * Add service as test resource * Move to test * More file moving * Remove from module-info, remove file * Make search business rules plugin extensible * fix ent search plugin * Delete dup files * [CI] Auto commit changes from spotless * Add module info back in --------- Co-authored-by: elasticsearchmachine <[email protected]> * top document no pinned * Removing this to see if it works without this transport version check, as i had made changes related to the cluster error * Fixed the retriever builder comments and error message * removed the unnencessary explain * Fixed all the tests in the yaml file * added extra test case * [CI] Auto commit changes from spotless --------- Co-authored-by: elasticsearchmachine <[email protected]> Co-authored-by: Kathleen DeRusso <[email protected]> (cherry picked from commit b742b02) # Conflicts: # server/src/main/java/org/elasticsearch/TransportVersions.java * Fixed the compile issue * changed pinned retriever name
In elastic#127623 we backported elastic#127299 and added a backport transport version for it - `ESQL_AGGREGATE_METRIC_DOUBLE_BLOCK_8_19` aka `8_841_0_24`. This brings that version forwards to `main` and adds support for parsing streams with that version. In elastic#127639 we backported elastic#126401 and added a backport transport version for it - `PINNED_RETRIEVER_8_19` aka `8_841_0_23`. This brings that version forwards to `main` and adds support for parsing streams with that versions. In elastic#127633 we a claimed a backport transport version to backport elastic#127314 - `INTRODUCE_FAILURES_LIFECYCLE_BACKPORT_8_19` aka `8_841_0_23`. That's the same versions as `PINNED_RETRIEVER_8_19`. It's just that this one is in `main` and `PINNED_RETRIEVER_8_19` is in `8.19`. To allow me to bring `PINNED_RETRIEVER_8_19` for wards I've had to revert elastic#127633. Closes elastic#127667
In #127623 we backported #127299 and added a backport transport version for it - `ESQL_AGGREGATE_METRIC_DOUBLE_BLOCK_8_19` aka `8_841_0_24`. This brings that version forwards to `main` and adds support for parsing streams with that version. In #127639 we backported #126401 and added a backport transport version for it - `PINNED_RETRIEVER_8_19` aka `8_841_0_23`. This brings that version forwards to `main` and adds support for parsing streams with that versions. In #127633 we a claimed a backport transport version to backport #127314 - `INTRODUCE_FAILURES_LIFECYCLE_BACKPORT_8_19` aka `8_841_0_23`. That's the same versions as `PINNED_RETRIEVER_8_19`. It's just that this one is in `main` and `PINNED_RETRIEVER_8_19` is in `8.19`. To allow me to bring `PINNED_RETRIEVER_8_19` for wards I've had to revert #127633. Closes #127667
Pinned Retriever for Elasticsearch
This PR introduces a new
pinned
retriever for Elasticsearch, available under thesearch-business-rules
plugin.The
pinned
retriever allows users to explicitly pin specific documents (viaids
ordocs
) so they always appear at the top of the search results, regardless of their organic relevance score. It is implemented as a compound retriever that rewrites internally to aPinnedQueryBuilder
.Key Features
_id
or by providing inline doc content."explain": true
, the search response now includes a custom_explanation
field for pinned results.Example:
Example API Request
Sample Response