Querying Nested Type content


(Karthik Ramachandran) #1

I'm trying to see if the below are possible using Elastic search querying. I'm finding it hard, but looks like these are not possible.

My content structure looks someething like below. It is a document with multiple nested type values.

{
Attr1: YYYY-mm-dd
Attr2: Single Term Value
Attr3: Array of strings
Attr4: Number Value
Attr5: String (analyzed - it is the only analyzed item)
List1:{ type:nested,
properties:{List1Attr1:string,List1Attr2:Number Value, List1Attr3:True/False}
}
List2:{ type:nested,
properties:{List2Attr1:string,List2Attr2:Number Value, List2Attr3:True/False}
}
}

I need output like

List1.List1Attr, List2.List2Attr1, count(documents),AVG(List1Attr2)

In SQL terms, it is something like

SELECT List1.List1Attr, List2.List2Attr1, COUNT(Master.Key),AVG(List1.List1Attr2)
FROM Master
JOIN List1 <>
JOIN List2 <>
GROUP BY List1.List1Attr, List2.List2Attr1

Note: I need to have the above two lists as nested type or I can make parent child, but it is business need.

I'm also trying with another mapping type where I'm eliminating to have two nested type instead have one. But no success so far. In this case the mapping would

CombinedList:{type:nested
,properties:{ListType:string,ListAttr1:string,ListAttr2:number,listAttr3:true/false}}

Any help is appreciated.


(system) #2