Hi all,

I was wondering if it is possible to apply aggregations only on a set of 
nested objects (not all nested objects presents inside a document), 
according to a property of this object? I think an example will help to 
understand.

Let's say that you have the following documents inthe index:

{
       "a": 2,
       "b": 3,
       "c": 4,
       "d": [
              {
                     "toto": 1,
                     "tutu": 2,
                     "titi": 3
              },
              {
                     "toto": 2,
                     "tutu": 5,
                     "titi": 6
              },
              {
                     "toto": 3,
                     "tutu": 11,
                     "titi": 8
              },
              {
                     "toto": 4,
                     "tutu": 7,
                     "titi": 4
              }
       ]
}




{
       "a": 3,
       "b": 4,
       "c": 5,
       "d": [
              {
                     "toto": 1,
                     "tutu": 10,
                     "titi": 6
              },
              {
                     "toto": 2,
                     "tutu": 65,
                     "titi": 8
              },
              {
                     "toto": 3,
                     "tutu": 25,
                     "titi": 15
              },
              {
                     "toto": 4,
                     "tutu": 30,
                     "titi": 45
              }
       ]
}



Where "d" is indexed as nested. I would like to get the maximum value for 
the "tutu" property from this kind of documents, but I would like to work 
only on nested objects where "toto" = 1. Here, I would like to get 10 (the 
red one in the samples), and not 65.

Is it possible to do this kind of aggregation? Or have I to change my 
document structure (or index mapping or ...)? If it is possible, could you 
point me how to do it? I had a look at nested aggregations and filter ones, 
but I am not sure that it could help.

Thank you for your replies.

Regards,
Loïc

-- 
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/681f7e7f-6340-4699-88f4-bb99032e47b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to