2019-08-20 06:38:22 -04:00
|
|
|
[role="xpack"]
|
|
|
|
[testenv="basic"]
|
|
|
|
[[query-dsl-pinned-query]]
|
|
|
|
=== Pinned Query
|
|
|
|
Promotes selected documents to rank higher than those matching a given query.
|
|
|
|
This feature is typically used to guide searchers to curated documents that are
|
|
|
|
promoted over and above any "organic" matches for a search.
|
|
|
|
The promoted or "pinned" documents are identified using the document IDs stored in
|
|
|
|
the <<mapping-id-field,`_id`>> field.
|
|
|
|
|
|
|
|
==== Example request
|
|
|
|
|
2019-09-09 12:35:50 -04:00
|
|
|
[source,console]
|
2019-08-20 06:38:22 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
GET /_search
|
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
"query": {
|
|
|
|
"pinned": {
|
|
|
|
"ids": [ "1", "4", "100" ],
|
|
|
|
"organic": {
|
|
|
|
"match": {
|
|
|
|
"description": "iphone"
|
2019-08-20 06:38:22 -04:00
|
|
|
}
|
2020-07-21 15:49:58 -04:00
|
|
|
}
|
2019-08-20 06:38:22 -04:00
|
|
|
}
|
2020-07-21 15:49:58 -04:00
|
|
|
}
|
|
|
|
}
|
2019-08-20 06:38:22 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
[[pinned-query-top-level-parameters]]
|
|
|
|
==== Top-level parameters for `pinned`
|
|
|
|
|
|
|
|
`ids`::
|
|
|
|
An array of <<mapping-id-field, document IDs>> listed in the order they are to appear in results.
|
|
|
|
`organic`::
|
2019-11-22 04:55:08 -05:00
|
|
|
Any choice of query used to rank documents which will be ranked below the "pinned" document ids.
|