[Aggregation] Be able to count number of item in a sub-collection

Hello

I have the following data

[
{
"id": 1,
"collection": [
{
"key": "val1"
},
{
"key": "val2"
},
{
"key": "val3"
}
]
},
{
"id": 2,
"collection": [
{
"key": "val1"
},
{
"key": "val2"
}
]
}
]

And I would like to be able to get a repartition of the number of items
into the
“collection” key. For example, With my sample, I expect something like:

  • 1 documents has 3 items
  • 1 document has 2 items

And then, after getting this king of information, I would like to be able to
query ES to ask something like “give me all document that have 2 items
under the
collection property”.

I dig into the documentation, test lot of things with sens, but nothing
give me the expected result.

So I have few questions:

  • Is it possible?
  • If yes, where can I find the doc?
  • If no, is it because I did not understand ES correctly?

Thanks :wink:

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/c5973012-9388-44c1-823c-dbc0828ff353%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Could you not add a count of items in the collection at index time? In this case you could filter on this value.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/1cb1b906-1ba2-4099-bd3c-76163e27f196%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yes and no :wink: Because I would like to be able to also filter node in the
collection. And then cound.
Actually, the collection contains orders, and I want to be able to know how
many paid order I get for a user.

On Friday, June 27, 2014 8:40:49 AM UTC+2, Timber wrote:

Could you not add a count of items in the collection at index time? In
this case you could filter on this value.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8a2b4608-a54a-4c76-813a-e6a2d810c697%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.