Skip to content

Add sorting section to the pinned query documentation #113856

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/reference/query-dsl/pinned-query.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
}
--------------------------------------------------