# Having issues translating query dsl to NEST

**URL:** <https://discuss.elastic.co/t/having-issues-translating-query-dsl-to-nest/310697>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [July 27, 2022, 12:48am UTC](https://discuss.elastic.co/t/having-issues-translating-query-dsl-to-nest/310697 "2022-07-27T00:48:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![charlene](https://avatars.discourse-cdn.com/v4/letter/c/eada6e/32.png) [@charlene](https://discuss.elastic.co/u/charlene)\
**Post date:** [July 27, 2022, 12:48am UTC](https://discuss.elastic.co/t/having-issues-translating-query-dsl-to-nest/310697/1 "2022-07-27T00:48:27Z")

</div>

I am using the nuget Nest(7.17.4) and am particular stucked at translating the fluent query dsl ...I thought there would be some syntax or any method I can utilize in Nest to simply paste the request queries (from inspect) for each dashboard items and then I can focus on my visualization, however that is not the case. I can use

```auto
.Query(q => q
                    .Raw(json_str.ToString())
                    )

```

But the aggregation and the rest of the request has to be done with the Nest language (It's called Fluent DSL I think?) And since I will have to scroll to get all the data, but in some cases I don't know where to put my scroll.. I still never get the same data as the dashboard shown on my kibana nor do I know how to get the query right.

For example:

There's this request I got from inspecting a table in my dashboard (count my\_record occurence and get the top five) :

```auto
{
  "aggs": {
    "2": {
      "terms": {
        "field": "my_record.keyword",
        "order": {
          "_count": "desc"
        },
        "size": 5
      }
    }
  },
  "size": 0,
  "fields": [
    {
      "field": "SystemTime",
      "format": "date_time"
    }
  ],
  "script_fields": {},
  "stored_fields": [
    "*"
  ],
  "runtime_mappings": {},
  "_source": {
    "excludes": []
  },
  "query": {
   .........my raw query in json file.......
  }
}

```

In my .net application I have sth like this:

```auto
 var json_str = System.IO.File.ReadAllText(@"my_json_file_location");
                results = _client.Search<Records>(s => s
                    .Aggregations(a => a
                      .Terms("2", t => t
                          .Field("my_record.keyword")
                          .Order(o => o.CountDescending())
                          .Size(5)
                          )
                     )
                    .Size(0)
                    .Fields(f => f
                        .Field("SystemTime")
                    .StoredFields("*")
                    .Query(q => q
                    .Raw(json_str.ToString())
                    )
                );

```

I wonder if there is an effective way to perform the translation? any tips, suggestions, advices would be very much appreciated. Thanks!

---

<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:** [August 24, 2022, 12:48am UTC](https://discuss.elastic.co/t/having-issues-translating-query-dsl-to-nest/310697/2 "2022-08-24T00:48:55Z")

</div>

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