From c1ee423f8cd96eae1d5c8e3916b32d2ed49fd4fa Mon Sep 17 00:00:00 2001 From: Nils S Date: Tue, 1 Oct 2024 13:46:57 +0200 Subject: [PATCH] Add a sorting section to the pinned query --- .../reference/query-dsl/pinned-query.asciidoc | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/reference/query-dsl/pinned-query.asciidoc b/docs/reference/query-dsl/pinned-query.asciidoc index dd437f9d5d106..ecb3722a3cc16 100644 --- a/docs/reference/query-dsl/pinned-query.asciidoc +++ b/docs/reference/query-dsl/pinned-query.asciidoc @@ -78,3 +78,33 @@ GET /_search <1> The document with id `1` from `my-index-000001` will be the first result. <2> When `_index` is missing, all documents with id `4` from the queried indices will be pinned with the same score. + +==== Sorting + +The `pinned` query internally uses the calculated relevance to pin the requested documents to the top of the results set. + +As soon any sorting is involved, the pinned query will be have no effect. + +[source,console] +-------------------------------------------------- +POST /_search +{ + "sort": [ + { + "price": { + "order": "desc" + } + } + ], + "query": { + "pinned": { + "ids": [ "1", "4"], + "organic": { + "match": { + "description": "iphone" + } + } + } + } +} +--------------------------------------------------