# ElasticSearch 7.11 - how to reproduce function with NEST?

**URL:** <https://discuss.elastic.co/t/elasticsearch-7-11-how-to-reproduce-function-with-nest/286487>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [October 12, 2021, 12:08pm UTC](https://discuss.elastic.co/t/elasticsearch-7-11-how-to-reproduce-function-with-nest/286487 "2021-10-12T12:08:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vadym\_Romanenko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vadym_romanenko/32/78657_2.png) [@Vadym\_Romanenko](https://discuss.elastic.co/u/Vadym_Romanenko)\
**Post date:** [October 12, 2021, 12:08pm UTC](https://discuss.elastic.co/t/elasticsearch-7-11-how-to-reproduce-function-with-nest/286487/1 "2021-10-12T12:08:24Z")

</div>

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:

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

```

I tried to generate such query function in this way:

```auto
              .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:

```auto
"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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 9, 2021, 12:08pm UTC](https://discuss.elastic.co/t/elasticsearch-7-11-how-to-reproduce-function-with-nest/286487/2 "2021-11-09T12:08:46Z")

</div>

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