# Index in key and value form

**URL:** <https://discuss.elastic.co/t/index-in-key-and-value-form/107128>\
**Category:** Elasticsearch\
**Created:** [November 10, 2017, 4:57am UTC](https://discuss.elastic.co/t/index-in-key-and-value-form/107128 "2017-11-10T04:57:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shekhar\_Pandey](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shekhar\_Pandey](https://discuss.elastic.co/u/Shekhar_Pandey)\
**Post date:** [November 10, 2017, 4:57am UTC](https://discuss.elastic.co/t/index-in-key-and-value-form/107128/1 "2017-11-10T04:57:42Z")

</div>

How can I get result like this..."search\_data": [  
....  
"string\_facet": [  
{  
"facet-name": "manufacturer",  
"facet-value": "Fortis"  
},  
{  
"facet-name": "hammer\_weight",  
"facet-value": "1000"  
}  
],  
"number\_facet": [  
{  
"facet-name": "final\_gross\_price",  
"facet-value": 822  
}  
]  
},

means..result after index coming in key and value form .....but my result like this..  
"title": "Asus MemoPad ME172V-1A076A 17c",  
"features": "",  
"fs\_description": "",  
"price": 3994,  
"last\_update": "2017-11-03T05:30:58.000Z",  
"fsid": "",  
"@version": "1",  
"id": 10000000844,  
"brand": "ASUS",  
"fs\_updated": 0,

I change in setting and use the nested type...but still result like above...any idea...

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [November 10, 2017, 9:33am UTC](https://discuss.elastic.co/t/index-in-key-and-value-form/107128/2 "2017-11-10T09:33:37Z")

</div>

I have not fully understood what you are after here.

First, it seems you are searching not for individual hits in your search response, but rather for aggregations. So first thing you should take a look at are [aggregations](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-aggregations.html).

If this is not the case, please take some more time to explain what you are after. What you cannot do is to modify the JSON response during your search. When a search hit is returned it always contains the original JSON.

---

<div class="post-metadata">

**Author:** ![Shekhar\_Pandey](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shekhar\_Pandey](https://discuss.elastic.co/u/Shekhar_Pandey)\
**Post date:** [November 10, 2017, 9:41am UTC](https://discuss.elastic.co/t/index-in-key-and-value-form/107128/3 "2017-11-10T09:41:28Z")

</div>

Hi spinscale!  
Thanks for answer. Actually I want to store my data in key and value form like this  
jsondata": """  
{  
"facet\_name": "size",  
"facet\_value": "S"  
},  
{  
"facet\_name": "color",  
"facet\_value": "black"  
},  
{  
"facet\_name": "fabric",  
"facet\_value": "cotton"  
}  
But I am using mysql and there is every field comes under \_source like this...  
....  
"product\_name": "sildenafil citrate",  
"supplier": "Wisozk Inc",  
"quantity": 261,  
"unit\_cost": "$10.47"  
....  
I tried also nested but result not get....  
can you just me some idea....

Thank you.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [November 10, 2017, 9:43am UTC](https://discuss.elastic.co/t/index-in-key-and-value-form/107128/4 "2017-11-10T09:43:59Z")

</div>

ah, got it. So this is not an Elasticsearch issue, but a pure ingestion issue. You need to fix your tooling, which indexes into Elasticsearch to properly prepare the JSON.

---

<div class="post-metadata">

**Author:** ![Shekhar\_Pandey](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shekhar\_Pandey](https://discuss.elastic.co/u/Shekhar_Pandey)\
**Post date:** [November 10, 2017, 9:45am UTC](https://discuss.elastic.co/t/index-in-key-and-value-form/107128/5 "2017-11-10T09:45:11Z")

</div>

Hi Spinscale....I am using logstash.....Have you any idea...about this...

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [November 13, 2017, 8:24am UTC](https://discuss.elastic.co/t/index-in-key-and-value-form/107128/6 "2017-11-13T08:24:12Z")

</div>

just move over to logstash and ask your question there, just provide all your configuration to make it easier for others to answer your questions.

---

<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 11, 2017, 8:24am UTC](https://discuss.elastic.co/t/index-in-key-and-value-form/107128/7 "2017-12-11T08:24:18Z")

</div>

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