# \[Aggregation Query\] Recreate kibana dashboards in asp.net core

**URL:** <https://discuss.elastic.co/t/aggregation-query-recreate-kibana-dashboards-in-asp-net-core/310373>\
**Category:** Elasticsearch\
**Tags:** language-clients, runtime-fields\
**Created:** [July 22, 2022, 8:47am UTC](https://discuss.elastic.co/t/aggregation-query-recreate-kibana-dashboards-in-asp-net-core/310373 "2022-07-22T08:47:39Z")\
**Posts on this page:** 3\
**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 22, 2022, 8:47am UTC](https://discuss.elastic.co/t/aggregation-query-recreate-kibana-dashboards-in-asp-net-core/310373/1 "2022-07-22T08:47:39Z")

</div>

Hi all, I am looking for ways to recreate my kibana dashboards on my own website (wanna do a little more one the visuals) , thus I have to get data from elasticsearch and query them and then visualize them.

I am using the nuget Nest(7.17.4) and am particular stucked at 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 anyone has done anything similiar, any tips, suggestions, advices would be very much appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 27, 2022, 1:36am UTC](https://discuss.elastic.co/t/aggregation-query-recreate-kibana-dashboards-in-asp-net-core/310373/2 "2022-07-27T01:36:56Z")

</div>

Just for future reference, you can click the 3 little dots at the bottom of the post and then edit it 🙂

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 27, 2022, 1:36am UTC](https://discuss.elastic.co/t/aggregation-query-recreate-kibana-dashboards-in-asp-net-core/310373/3 "2022-07-27T01:36:59Z")

</div>


