You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/elasticsearch/rest-apis/retrievers.md
+49-73Lines changed: 49 additions & 73 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,79 +41,12 @@ The following retrievers are available:
41
41
`text_similarity_reranker`
42
42
: A [retriever](#text-similarity-reranker-retriever) that enhances search results by re-ranking documents based on semantic similarity to a specified inference text, using a machine learning model.
43
43
44
+
`pinned`
45
+
: A [retriever](#pinned-retriever) that always places specified documents at the top of the results, with the remaining hits provided by a secondary retriever.
46
+
44
47
`rule`
45
48
: A [retriever](#rule-retriever) that applies contextual [Searching with query rules](/reference/elasticsearch/rest-apis/searching-with-query-rules.md#query-rules) to pin or exclude documents for specific queries.
46
49
47
-
## Pinned Retriever [pinned-retriever]
48
-
49
-
A `pinned` retriever returns top documents by always placing specific documents at the top of the results, in the order provided. This is useful for promoting certain documents for particular queries, regardless of their relevance score. The remaining results are filled by a fallback retriever.
50
-
51
-
#### Parameters [pinned-retriever-parameters]
52
-
53
-
`ids`
54
-
: (Optional, array of strings)
55
-
56
-
A list of document IDs to pin at the top of the results, in the order provided.
57
-
58
-
`documents`
59
-
: (Optional, array of objects)
60
-
61
-
A list of objects specifying documents to pin. Each object must contain at least an `_id` field, and may also specify `_index` if pinning documents across multiple indices.
62
-
63
-
`fallback`
64
-
: (Optional, retriever object)
65
-
66
-
A retriever to use for retrieving the remaining documents after the pinned ones.
67
-
68
-
Either `ids` or `documents` must be specified.
69
-
70
-
### Example using `ids`[pinned-retriever-example-ids]
71
-
72
-
```console
73
-
GET /restaurants/_search
74
-
{
75
-
"retriever": {
76
-
"pinned": {
77
-
"ids": ["doc1", "doc2"],
78
-
"fallback": {
79
-
"standard": {
80
-
"query": {
81
-
"match": {
82
-
"title": "elasticsearch"
83
-
}
84
-
}
85
-
}
86
-
}
87
-
}
88
-
}
89
-
}
90
-
```
91
-
92
-
### Example using `documents`[pinned-retriever-example-documents]
93
-
94
-
```console
95
-
GET /restaurants/_search
96
-
{
97
-
"retriever": {
98
-
"pinned": {
99
-
"documents": [
100
-
{ "_id": "doc1", "_index": "my-index" },
101
-
{ "_id": "doc2" }
102
-
],
103
-
"fallback": {
104
-
"standard": {
105
-
"query": {
106
-
"match": {
107
-
"title": "elasticsearch"
108
-
}
109
-
}
110
-
}
111
-
}
112
-
}
113
-
}
114
-
}
115
-
```
116
-
117
50
## Standard Retriever [standard-retriever]
118
51
119
52
A standard retriever returns top documents from a traditional [query](/reference/query-languages/querydsl.md).
@@ -991,7 +924,53 @@ GET movies/_search
991
924
1. The `rule` retriever is the outermost retriever, applying rules to the search results that were previously reranked using the `rrf` retriever.
992
925
2. The `rrf` retriever returns results from all of its sub-retrievers, and the output of the `rrf` retriever is used as input to the `rule` retriever.
993
926
927
+
## Pinned Retriever [pinned-retriever]
928
+
929
+
A `pinned` retriever returns top documents by always placing specific documents at the top of the results, with the remaining hits provided by a secondary retriever. This retriever offers similar functionality to the [pinned query](/reference/query-languages/query-dsl/query-dsl-pinned-query.md), but works seamlessly with other retrievers. This is useful for promoting certain documents for particular queries, regardless of their relevance score.
930
+
931
+
#### Parameters [pinned-retriever-parameters]
932
+
933
+
`ids`
934
+
: (Optional, array of strings)
935
+
936
+
A list of document IDs to pin at the top of the results, in the order provided.
937
+
938
+
`documents`
939
+
: (Optional, array of objects)
940
+
941
+
A list of objects specifying documents to pin. Each object must contain at least an `_id` field, and may also specify `_index`if pinning documents across multiple indices.
942
+
943
+
`retriever`
944
+
: (Optional, retriever object)
994
945
946
+
A retriever (for example a `standard` retriever or a specialized retriever such as `rrf` retriever) used to retrieve the remaining documents after the pinned ones.
947
+
948
+
Either `ids` or `documents` must be specified.
949
+
950
+
### Example using `documents` [pinned-retriever-example-documents]
951
+
952
+
```console
953
+
GET /restaurants/_search
954
+
{
955
+
"retriever": {
956
+
"pinned": {
957
+
"documents": [
958
+
{ "_id": "doc1", "_index": "my-index" },
959
+
{ "_id": "doc2" }
960
+
],
961
+
"retriever": {
962
+
"standard": {
963
+
"query": {
964
+
"match": {
965
+
"title": "elasticsearch"
966
+
}
967
+
}
968
+
}
969
+
}
970
+
}
971
+
}
972
+
}
973
+
```
995
974
996
975
## Common usage guidelines [retriever-common-parameters]
997
976
@@ -1016,6 +995,3 @@ When a retriever is specified as part of a search, the following elements are no
0 commit comments