# How to use elastic search for storing & fetching document as json

**URL:** <https://discuss.elastic.co/t/how-to-use-elastic-search-for-storing-fetching-document-as-json/245232>\
**Category:** Elasticsearch\
**Created:** [August 17, 2020, 12:13pm UTC](https://discuss.elastic.co/t/how-to-use-elastic-search-for-storing-fetching-document-as-json/245232 "2020-08-17T12:13:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmuzammil45](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@mmuzammil45](https://discuss.elastic.co/u/mmuzammil45)\
**Post date:** [August 17, 2020, 12:13pm UTC](https://discuss.elastic.co/t/how-to-use-elastic-search-for-storing-fetching-document-as-json/245232/1 "2020-08-17T12:13:12Z")

</div>

I am working on ElasticSearch for the purpose of storing & fetching data as json. The problem is ES treats json as text/string when I use search/highlight function and does not complete my requirement i.e. to get all the parents of stored json in the search result. For example if I have a json like this:

`{"jsonfile.htm":{"Headingtag":"100129","Sectiontext":{"part i":{"Headingtag":"p1","Sectiontext":{"Random Heading I":{"Sectiontext":"Impossible considered invitation him men instrument saw celebrated unpleasant."},"Random Heading II":{"Sectiontext":"Prevailed discovery immediate objection of ye at."}}}}}}`

When we use search or highlight function for "celebrated" text, it gives me the result like this:

`[highlight] => Array ( [detail] => Array ( [0] => ":{"Random Heading I":{"Sectiontext":"Impossible considered invitation him men instrument saw celebrated ) )`

It consider json as string and ignores the parent child relation. Can anyone help me to find out how to fetch all the searched text parents in the result?

---

<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:** [September 14, 2020, 12:13pm UTC](https://discuss.elastic.co/t/how-to-use-elastic-search-for-storing-fetching-document-as-json/245232/2 "2020-09-14T12:13:13Z")

</div>

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