# ElasticSearch Head and nested JSON

**URL:** <https://discuss.elastic.co/t/elasticsearch-head-and-nested-json/10828>\
**Category:** Elasticsearch\
**Created:** [February 20, 2013, 10:42pm UTC](https://discuss.elastic.co/t/elasticsearch-head-and-nested-json/10828 "2013-02-20T22:42:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![caymanag](https://avatars.discourse-cdn.com/v4/letter/c/8dc957/32.png) [@caymanag](https://discuss.elastic.co/u/caymanag)\
**Post date:** [February 20, 2013, 10:42pm UTC](https://discuss.elastic.co/t/elasticsearch-head-and-nested-json/10828/1 "2013-02-20T22:42:01Z")

</div>

I have a question on how to use ES-Head with nested JSON documents. The  
problem appears to be when the nested document re-uses field names.

Here is my sample document  
{  
"a": {  
"b": {  
"c":"firstval",  
"b":"secondval"  
},  
"d": {  
"b":"thirdval"  
}  
}  
}

I can successfully query this document using curl as follows:  
curl -XGET 'localhost:9200/twitter/\_search?q=tweet.a.b.b=secondval'  
curl -XGET 'localhost:9200/twitter/\_search?q=tweet.a.d.b=thirdval'

However, I cannot get this to work for both cases in ES-Head.

In the Browser tab, I see the one document

\_index  
\_type  
\_id  
▼  
\_score  
c  
b  
twittertweet11firstvalthirdval

Under Fields (on the left), I can only search for the a.b.b field. It  
doesn't appear to allow me to search on the a.d.b field.

Under the Structured Query tab I can select either the a.b.b field or the  
a.d.b field. However, the search does not succeed for the the a.d.b field.

The problem is apparently due to the repeated use of the same field name.  
If I modify the document and rename the field a.d.b to a.d.somethingelse,  
then the queries work fine.

This isn't just an academic exercise. My documents have numerous duplicate  
field names and it would be inconvenient to replace them with unique names.

ES-Head is an excellent tool. Thank you.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mobz\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mobz_2/32/2473_2.png) [@mobz\_2](https://discuss.elastic.co/u/mobz_2)\
**Post date:** [February 24, 2013, 11:13am UTC](https://discuss.elastic.co/t/elasticsearch-head-and-nested-json/10828/2 "2013-02-24T11:13:00Z")

</div>

Hi,

Please see issues tracking this problem on github for more info

[field names not qualified · Issue #36 · mobz/elasticsearch-head · GitHub](https://github.com/mobz/elasticsearch-head/issues/36) (fixed) and  
[Column headers on browser should be path not field\_name · Issue #45 · mobz/elasticsearch-head · GitHub](https://github.com/mobz/elasticsearch-head/issues/45) (not fixed)

Essentially, it's a design flaw dating from the earlier days of the  
project. I've fixed it on Structured Query, but it's a bit more tricky on  
the browser. There is a partial solution described on github. ymmv

-B

On Thursday, 21 February 2013 09:42:01 UTC+11, Cayman wrote:

> I have a question on how to use ES-Head with nested JSON documents. The  
> problem appears to be when the nested document re-uses field names.
> 
> Here is my sample document  
> {  
> "a": {  
> "b": {  
> "c":"firstval",  
> "b":"secondval"  
> },  
> "d": {  
> "b":"thirdval"  
> }  
> }  
> }
> 
> I can successfully query this document using curl as follows:  
> curl -XGET 'localhost:9200/twitter/\_search?q=tweet.a.b.b=secondval'  
> curl -XGET 'localhost:9200/twitter/\_search?q=tweet.a.d.b=thirdval'
> 
> However, I cannot get this to work for both cases in ES-Head.
> 
> In the Browser tab, I see the one document
> 
> \_index  
> \_type  
> \_id  
> ▼  
> \_score  
> c  
> b  
> twittertweet11firstvalthirdval
> 
> Under Fields (on the left), I can only search for the a.b.b field. It  
> doesn't appear to allow me to search on the a.d.b field.
> 
> Under the Structured Query tab I can select either the a.b.b field or the  
> a.d.b field. However, the search does not succeed for the the a.d.b field.
> 
> The problem is apparently due to the repeated use of the same field name.  
> If I modify the document and rename the field a.d.b to a.d.somethingelse,  
> then the queries work fine.
> 
> This isn't just an academic exercise. My documents have numerous  
> duplicate field names and it would be inconvenient to replace them with  
> unique names.
> 
> ES-Head is an excellent tool. Thank you.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:49am UTC](https://discuss.elastic.co/t/elasticsearch-head-and-nested-json/10828/3 "2017-07-06T02:49:53Z")

</div>


