Pinned Query Usageedit

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 _id field. See the Elasticsearch documentation on pinned query for more details.

Fluent DSL exampleedit

q
.Pinned(c => c
    .Name("named_query")
    .Boost(1.1)
    .Organic(qq => qq.MatchAll(m => m.Name("organic_query")))
    .Ids(1, 11, 22)
)

Object Initializer syntax exampleedit

new PinnedQuery()
{
    Name = "named_query",
    Boost = 1.1,
    Organic = new MatchAllQuery { Name = "organic_query" },
    Ids = new Id[] { 1,11,22 },
}

Example json output.

{
  "pinned": {
    "_name": "named_query",
    "boost": 1.1,
    "organic": {
      "match_all": {
        "_name": "organic_query"
      }
    },
    "ids": [
      1,
      11,
      22
    ]
  }
}