ElasticSearch 7.11 - how to reproduce function with NEST?

Good day for everyone!

I'm trying to reproduce generation of function that increases score for documents with specific values.
This is original part of the query that was created in ES console:

  "query": {
    "function_score": {
      "query": {
...
      }
      "boost": "1", 
      "functions": [
        {
          "filter": { "match": { "short_description": "Viking" } },
          "weight": 2
        },
....

I tried to generate such query function in this way:

              .Weight(w => w
                            .Weight(Decimal.ToDouble(2))
                            .Filter(fi => fi
                                .Match(m => m
                                    .Field("short_description")
                                    .Query("Viking")
                                )
                            )
                          )

but this code generates function in this way:

"functions": [
        {
          "filter": { "match": { "short_description": { "query": "Viking" } } },
          "weight": 2
        }

How should I modify my C# code with NEST to get generated request as specified in the start?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.