-
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
Merged
Merged
Pinned retriever #126401
Changes from all commits
Commits
Show all changes
100 commits
Select commit
Hold shift + click to select a range
84b6ed7
Created PinnedQueryRetriever Builder
mridula-s109 4c6f284
Added retriever build test file
mridula-s109 18bf6e4
Changed the test to accept all the retrievers as its not licensed
mridula-s109 8bab3d2
[CI] Auto commit changes from spotless
elasticsearchmachine 2cfcdc1
Added integration test and fixed the code style issues
mridula-s109 760415d
Fixed merge issues
mridula-s109 9bc751a
Merge branch 'main' into pinned-retriever
mridula-s109 63ac692
Merge branch 'main' into pinned-retriever
mridula-s109 eec5f60
Added cluster test feature to the integration tests
mridula-s109 69e14cc
Update docs/changelog/126401.yaml
mridula-s109 626ebac
Registered retriever plugin
mridula-s109 c724b75
Merge branch 'main' into pinned-retriever
mridula-s109 ef5f50f
Enhanced changelog description
mridula-s109 721b1d1
Added validation to the constructor creation
mridula-s109 a75926c
Introduced validations in the code and incorporated in tests - compil…
mridula-s109 c84028e
Included PinnedRankDoc to enhance the explain query, validations for …
mridula-s109 38e8d06
Merge branch 'main' into pinned-retriever
mridula-s109 4476564
Working on improving integration test and introducing cluster features
mridula-s109 eaee938
Removed cluster test temporarily
mridula-s109 2aad145
Got pinnedretriever yaml to working state without cluster
mridula-s109 08e5add
[CI] Auto commit changes from spotless
elasticsearchmachine daa528e
Resolved no source yaml error
mridula-s109 db1a149
Cluster loaded successfully
mridula-s109 e00c249
[CI] Auto commit changes from spotless
elasticsearchmachine c659c1c
Fixed integration test
mridula-s109 7ab4b76
Made validate sort less strict
mridula-s109 e1a4362
Included shareddoc sorting in the validate sort
mridula-s109 3e40f6e
All yaml issues resolved
mridula-s109 1d4eb6f
Explanation yaml files added
mridula-s109 05a05a0
Trying to add clustering to the test
mridula-s109 e2fc29b
[CI] Auto commit changes from spotless
elasticsearchmachine dc02f53
Removed explicit feature specification
mridula-s109 e2b8cb6
Deleted the empty file
mridula-s109 aefc0c6
Merge branch 'main' into pinned-retriever
mridula-s109 f621af0
Put the node feature in the proper place
mridula-s109 a3de636
Added additional validation in ids and docs
mridula-s109 5626dd7
Cleaned the create pinned query validation
mridula-s109 f19b718
made unit tests robust
mridula-s109 7e90b88
Remove query.es from version control
mridula-s109 923e154
Remove result.json from version control
mridula-s109 583324b
[CI] Auto commit changes from spotless
elasticsearchmachine aebe17a
Everything except explanation is fixed
mridula-s109 455db59
added duplicate doc test
mridula-s109 c5ff33d
Applied checkstyle fix, spotless and a failing yaml
mridula-s109 ba40533
Improvements based on PR comments
mridula-s109 4456504
[CI] Auto commit changes from spotless
elasticsearchmachine 3c86416
Modified the unit test to accomodate the change in createPinnedQuery
mridula-s109 f2035a6
Split the yaml to test for basic and trial, cleanedup and acted on al…
mridula-s109 516ed7c
Remove result.json and query.es from version control
mridula-s109 97c3376
Removed unnecessary comments
mridula-s109 ebbf1af
Removed redundant file
mridula-s109 dada60f
Merge branch 'main' into pinned-retriever
mridula-s109 9b30e87
Fixing CI build error
mridula-s109 095eac1
Merge branch 'main' into pinned-retriever
mridula-s109 374b37d
[CI] Auto commit changes from spotless
elasticsearchmachine 42dc070
Removed pinnedBy as it wasnt necessary
mridula-s109 d869c9e
Removed unnecessary ToXContent Information
mridula-s109 d67b291
Fixed transport version charges and cleaned up null checks:
mridula-s109 1c239d4
[CI] Auto commit changes from spotless
elasticsearchmachine 38c5dbf
Retriever status changed to 9.1 version
mridula-s109 40cd06b
cleaned up 2 yamltestsuite for different licenses
mridula-s109 8d3a36b
Trying to get the clustering works
mridula-s109 f63c78d
Cleaned up the yaml clustering and also reorganised the yaml tests
mridula-s109 e13f93e
Merge branch 'main' into pinned-retriever
mridula-s109 2f1c377
Unnecessary file introduction removed
mridula-s109 c979859
Reverted the plugins to the previous state as the changes werent nece…
mridula-s109 527a9bf
Removed unnecessary transport versioning from pinnedrankdoc
mridula-s109 42e5973
reverted
mridula-s109 f9ed13a
[CI] Auto commit changes from spotless
elasticsearchmachine 1aa42f8
Edited the SearchBusinessRules to remove the class from getFeatures
mridula-s109 92993d0
[CI] Auto commit changes from spotless
elasticsearchmachine 018a525
Cleaned up Pinned retriever to allow only id or docs
mridula-s109 137cc0d
Added more test to the pinned retriever
mridula-s109 1525069
did spotless
mridula-s109 0449bc6
Merge branch 'main' into pinned-retriever
mridula-s109 74f7a95
Introduced new transport versioning
mridula-s109 dea8d6c
Cleaning it up
mridula-s109 5d6575a
Resolved validate module error
mridula-s109 9bed922
Merge branch 'main' into pinned-retriever
mridula-s109 63a16db
Merge branch 'main' into pinned-retriever
mridula-s109 fae7a05
BWT issues
mridula-s109 4c4dee6
Merge branch 'main' into pinned-retriever
mridula-s109 5b5ede4
[CI] Auto commit changes from spotless
elasticsearchmachine 215523d
fix NPE occuring in ci
mridula-s109 27a33a0
trying to fix duplicate feature issue
mridula-s109 4c8b701
Merge branch 'main' into pinned-retriever
mridula-s109 4cfcbad
[CI] Auto commit changes from spotless
elasticsearchmachine 13f80fb
modified the tests
mridula-s109 2bfcb81
Merge branch 'main' into pinned-retriever
mridula-s109 247c78d
Playing with pinned retriever CI (#127530)
kderusso e86c6e0
Merge branch 'main' into pinned-retriever
mridula-s109 cbb8ab1
top document no pinned
mridula-s109 9bfcb4b
Removing this to see if it works without this transport version check…
mridula-s109 227011b
Fixed the retriever builder comments and error message
mridula-s109 84608c0
removed the unnencessary explain
mridula-s109 1a68442
Fixed all the tests in the yaml file
mridula-s109 29d16a2
added extra test case
mridula-s109 71c3439
merged main
mridula-s109 819e279
[CI] Auto commit changes from spotless
elasticsearchmachine bd29ce8
Merge branch 'main' into pinned-retriever
mridula-s109 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 126401 | ||
summary: Add pinned retriever | ||
area: Relevance | ||
type: enhancement | ||
issues: [] |
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
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
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
98 changes: 98 additions & 0 deletions
98
...gin/rank-rrf/src/yamlRestTest/resources/rest-api-spec/test/rrf/950_pinned_interaction.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
setup: | ||
- requires: | ||
cluster_features: 'pinned_retriever_supported' | ||
reason: 'test requires pinned retriever implementation' | ||
- do: | ||
indices.create: | ||
index: test-index1 | ||
|
||
- do: | ||
bulk: | ||
refresh: true | ||
index: test-index1 | ||
body: | ||
- index: | ||
_id: doc1 | ||
- { "text": "document one" } | ||
- index: | ||
_id: doc2 | ||
- { "text": "document two" } | ||
- index: | ||
_id: doc3 | ||
- { "text": "document three" } | ||
- index: | ||
_id: doc4 | ||
- { "text": "document four" } | ||
- index: | ||
_id: doc5 | ||
- { "text": "document five" } | ||
|
||
--- | ||
"rrf combined with pinned retriever": | ||
- skip: { features: headers } | ||
- do: | ||
headers: | ||
Content-Type: application/json | ||
search: | ||
index: test-index1 | ||
body: | ||
retriever: | ||
pinned: | ||
ids: ["doc1"] | ||
retriever: | ||
rrf: | ||
retrievers: [ | ||
{ | ||
standard: { | ||
query: { | ||
term: { text: "document" } | ||
} | ||
} | ||
}, | ||
{ | ||
standard: { | ||
query: { | ||
term: { text: "three" } | ||
} | ||
} | ||
} | ||
] | ||
rank_window_size: 10 | ||
|
||
- match: { hits.total.value: 5 } | ||
- match: { hits.hits.0._id: doc1 } | ||
- match: { hits.hits.0._score: 1.7014122E38 } | ||
- match: { hits.hits.1._id: doc3 } | ||
- match: { hits.hits.1._score < 100.0 } | ||
- match: { hits.hits.2._id: doc2 } | ||
|
||
--- | ||
"rrf with pinned retriever as a sub-retriever": | ||
- skip: { features: headers } | ||
- do: | ||
headers: { Content-Type: application/json } | ||
search: | ||
index: test-index1 | ||
body: | ||
retriever: | ||
rrf: | ||
retrievers: | ||
- | ||
standard: | ||
query: | ||
match: { text: "document" } | ||
- | ||
pinned: | ||
ids: ["doc4", "doc5"] | ||
retriever: | ||
standard: | ||
query: | ||
match: { text: "document" } | ||
|
||
- match: { hits.total.value: 5 } | ||
- match: { hits.hits.0._id: doc1 } | ||
mridula-s109 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- lt: { hits.hits.0._score: 100.0 } | ||
- match: { hits.hits.1._id: doc4 } | ||
- match: { hits.hits.2._id: doc5 } | ||
|
||
|
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
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
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
mridula-s109 marked this conversation as resolved.
Show resolved
Hide resolved
|
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
28 changes: 28 additions & 0 deletions
28
...rc/main/java/org/elasticsearch/xpack/searchbusinessrules/SearchBusinessRulesFeatures.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.searchbusinessrules; | ||
|
||
import org.elasticsearch.features.FeatureSpecification; | ||
import org.elasticsearch.features.NodeFeature; | ||
|
||
import java.util.Set; | ||
|
||
import static org.elasticsearch.xpack.searchbusinessrules.retriever.PinnedRetrieverBuilder.PINNED_RETRIEVER_FEATURE; | ||
|
||
public class SearchBusinessRulesFeatures implements FeatureSpecification { | ||
|
||
@Override | ||
public Set<NodeFeature> getFeatures() { | ||
return Set.of(); | ||
} | ||
|
||
@Override | ||
public Set<NodeFeature> getTestFeatures() { | ||
return Set.of(PINNED_RETRIEVER_FEATURE); | ||
} | ||
} |
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
81 changes: 81 additions & 0 deletions
81
...es/src/main/java/org/elasticsearch/xpack/searchbusinessrules/retriever/PinnedRankDoc.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.searchbusinessrules.retriever; | ||
|
||
import org.apache.lucene.search.Explanation; | ||
import org.elasticsearch.TransportVersion; | ||
import org.elasticsearch.TransportVersions; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.search.rank.RankDoc; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
public class PinnedRankDoc extends RankDoc { | ||
public static final String NAME = "pinned_rank_doc"; | ||
|
||
private final boolean isPinned; | ||
|
||
public PinnedRankDoc(int docId, float score, int shardIndex, boolean isPinned) { | ||
super(docId, score, shardIndex); | ||
this.isPinned = isPinned; | ||
} | ||
|
||
public PinnedRankDoc(StreamInput in) throws IOException { | ||
super(in); | ||
this.isPinned = in.readBoolean(); | ||
} | ||
|
||
public boolean isPinned() { | ||
return isPinned; | ||
} | ||
|
||
@Override | ||
public Explanation explain(Explanation[] sources, String[] queryNames) { | ||
mridula-s109 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (isPinned) { | ||
return Explanation.match(score, "Pinned document, original explanation:", sources); | ||
} else { | ||
return super.explain(sources, queryNames); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return super.toString() + ", isPinned=" + isPinned; | ||
} | ||
|
||
@Override | ||
public String getWriteableName() { | ||
return NAME; | ||
} | ||
|
||
@Override | ||
protected void doWriteTo(StreamOutput out) throws IOException { | ||
out.writeBoolean(isPinned); | ||
} | ||
|
||
@Override | ||
protected boolean doEquals(RankDoc rd) { | ||
if (rd instanceof PinnedRankDoc other) { | ||
return this.isPinned == other.isPinned; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
protected int doHashCode() { | ||
return Objects.hash(super.doHashCode(), isPinned); | ||
} | ||
|
||
@Override | ||
public TransportVersion getMinimalSupportedVersion() { | ||
return TransportVersions.PINNED_RETRIEVER; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
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