Rank Feature Query Usageedit

The rank_feature query is a specialized query that only works on rank_feature fields and rank_features fields. Its goal is to boost the score of documents based on the values of numeric features. It is typically put in a should clause of a bool query so that its score is added to the score of the query.

Compared to using function_score or other ways to modify the score, this query has the benefit of being able to efficiently skip non-competitive hits when track_total_hits is not set to true. Speedups may be spectacular.

See the Elasticsearch documentation on rank feature query for more details.

Fluent DSL exampleedit

q
.RankFeature(rf => rf
    .Name("named_query")
    .Boost(1.1)
    .Field(f => f.Rank)
    .Saturation()
)

Object Initializer syntax exampleedit

new RankFeatureQuery()
{
    Name = "named_query",
    Boost = 1.1,
    Field = Infer.Field<Project>(f => f.Rank),
    Function = new RankFeatureSaturationFunction()
}

Example json output. 

{
  "rank_feature": {
    "_name": "named_query",
    "boost": 1.1,
    "field": "rank",
    "saturation": {}
  }
}