Hi, For this you need to use nested documents and the nested aggregation[1], I just wrote a query that should give the expected results: https://gist.github.com/jpountz/9411624
[1] http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-nested-aggregation.html On Fri, Mar 7, 2014 at 9:42 AM, <[email protected]> wrote: > Hello: > I got a problem in facet, for example I have person documents defined as > following > > person = { > name:'personName1', > attributes:[ > { > name:'attributeName1', > value:'attributeName1Value1' > }, > { > name:'attributeName2', > value:'attributeName2Value1' > }, > { > name:'attributeName3', > value:'attributeName3Value1' > } > ] > } > > each person contains one name and a list of attributes, and each attribute > contains name and value. > each attribute name e.g 'attributeName1' might have several possible > values 'attrbuteName1Value1','attributeName1Value2',attributeName1Value3.... > I have a lot of person documents combined with different attribute names > with different possible attribute values > > I want to define a facet to query how many person in specific attribute > name > e.g. how many persons with attribute name 'attributeName1' > the result would be: > facet = { > person_attributes_attribute_name_1:{ > terms:[ > { > "term":"attributeName1Value1", > "count":1000 > }, > { > "term":"attributeName1Value2", > "count":1300 > }, > { > "term":"attributeName1Value3", > "count":700 > } > ] > } > } > > thanks > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elasticsearch/2a10f9b0-c8ad-42ae-80a2-914cfa32cfa5%40googlegroups.com<https://groups.google.com/d/msgid/elasticsearch/2a10f9b0-c8ad-42ae-80a2-914cfa32cfa5%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Adrien Grand -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j68Cp5xdvtWVwT4yUqDgbNVDCH%3DCcUEvf0wo_6oNNe0nw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
