# Using Nested Field like main data source

**URL:** <https://discuss.elastic.co/t/using-nested-field-like-main-data-source/208571>\
**Category:** Elasticsearch\
**Created:** [November 19, 2019, 7:51pm UTC](https://discuss.elastic.co/t/using-nested-field-like-main-data-source/208571 "2019-11-19T19:51:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![salihklc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/salihklc/32/79520_2.png) [@salihklc](https://discuss.elastic.co/u/salihklc)\
**Post date:** [November 19, 2019, 7:51pm UTC](https://discuss.elastic.co/t/using-nested-field-like-main-data-source/208571/1 "2019-11-19T19:51:23Z")

</div>

Hello everyone,

I'm developing a website which using elasticsearch for showing data on datatable with  
fully supported features (paging,sorting, etc.) (you can see example data below, and easy to figure out thats a grocery application ).

```
{
amount:	596.5
cashAmount:	596.5
   	cashierName:"NURY"
   	creditAmount:0
   	currencyAmount:0
   	 dBInsertionDate:	"2019-12-30"
   "products":[
{ "productName":"apple","unit":4
},{
"productName":"orange","unit":2
}
]
}

```

In the begining I was getting my data with **products** and after customer clicking the row I was showing products of data.  
Everything was awesome until my client wanted to see new grid table with only shows nested (inner products) data on the datatable ofcourse with all datatable feature (paging,filtering,orderin etc.), I could index all **products** on another index (new one) and use new index for new datatable but that looks like bad practice and lots of wasting storage.

I will try using [**inner\_hits**](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#request-body-search-inner-hits) options, but I'm not sure I can implement that easily.

So I'm really need some advice to do that, cause looks like this will be extend after a month with more nested fields.

Thank you for your any advice 🤘

**Edit:**  
I search for it and looks like it's impossible to paging,sorting etc. in nested fields according to ES forum ([topic](https://www.elastic.co/blog/managing-relations-inside-elasticsearch)) ( [see also](https://stackoverflow.com/questions/29233742/inner-object-vs-denormalization-in-elastic-search)

**Edit2:**  
Now I'm going to index all nested parts as different index.That will be more efficient for future.

---

<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:** [December 17, 2019, 7:51pm UTC](https://discuss.elastic.co/t/using-nested-field-like-main-data-source/208571/2 "2019-12-17T19:51:23Z")

</div>

Closed on December 17, 2019, 7:51pm UTC

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