# How to get subtype's statistical data of nested object with dynamic query?

**URL:** <https://discuss.elastic.co/t/how-to-get-subtypes-statistical-data-of-nested-object-with-dynamic-query/13027>\
**Category:** Elasticsearch\
**Created:** [August 1, 2013, 3:39am UTC](https://discuss.elastic.co/t/how-to-get-subtypes-statistical-data-of-nested-object-with-dynamic-query/13027 "2013-08-01T03:39:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leoncin](https://avatars.discourse-cdn.com/v4/letter/l/d6d6ee/32.png) [@Leoncin](https://discuss.elastic.co/u/Leoncin)\
**Post date:** [August 1, 2013, 3:39am UTC](https://discuss.elastic.co/t/how-to-get-subtypes-statistical-data-of-nested-object-with-dynamic-query/13027/1 "2013-08-01T03:39:20Z")

</div>

Hello,  
In my project, we use nested object with different keys, for example,  
the following messages are indexed  
message1: {type: type1, nestedObj: {key1:value1, key2:  
value2}}  
message2: {type: type2, nestedObj: {key1:value3, key2:  
value4, key3:value5}}  
Maybe there are many different keys. Now we want to calculate how many  
different key are used for each type. Eg. type1 contains key1 and key2.  
type2 contains key1, key2 and key3.  
How can I get this data? Although I can get the \_mapping, but it  
contains all of the keys used in nestedObject for all types. And I also  
tried facet, it seems that my above requirement can't be met.

Thank you very much in advance.

--  
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:** ![Leoncin](https://avatars.discourse-cdn.com/v4/letter/l/d6d6ee/32.png) [@Leoncin](https://discuss.elastic.co/u/Leoncin)\
**Post date:** [August 5, 2013, 9:21am UTC](https://discuss.elastic.co/t/how-to-get-subtypes-statistical-data-of-nested-object-with-dynamic-query/13027/2 "2013-08-05T09:21:43Z")

</div>

Is there any work around to solve this problem?  
Appreciating your help!

在 2013年8月1日星期四UTC+8上午11时39分20秒，Leoncin写道：

> Hello,  
> In my project, we use nested object with different keys, for example,  
> the following messages are indexed  
> message1: {type: type1, nestedObj: {key1:value1, key2:  
> value2}}  
> message2: {type: type2, nestedObj: {key1:value3, key2:  
> value4, key3:value5}}  
> Maybe there are many different keys. Now we want to calculate how many  
> different key are used for each type. Eg. type1 contains key1 and key2.  
> type2 contains key1, key2 and key3.  
> How can I get this data? Although I can get the \_mapping, but it  
> contains all of the keys used in nestedObject for all types. And I also  
> tried facet, it seems that my above requirement can't be met.
> 
> Thank you very much in advance.

--  
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:22am UTC](https://discuss.elastic.co/t/how-to-get-subtypes-statistical-data-of-nested-object-with-dynamic-query/13027/3 "2017-07-06T02:22:58Z")

</div>

Closed on July 6, 2017, 2:22am UTC


