Child document grouping and filtering


(Tavoaqp) #1

Hi there

Suppose you have a document like this:

listing: {
id: "1",
name: "name1",
upinterval:[{start:"2016-10-01",end:"2016-12-25",id:"u11"}],
downinterval:[{start:"2016-10-10",end:"2016-10-29",id:"d11"},{start:"2016-12-05",end:"2016-12-10",id:"d12"}]
},
listing: {
id: "2",
name: "name2",
upinterval:[{start:"2016-11-28",end:"2017-01-25",id:"u21"}],
downinterval:[{start:"2016-12-24",end:"2017-01-01",id:"d21"},{start:"2017-01-10",end:"2017-01-15",id:"d22"}]
}

I've tried (without success) a query to retrieve a list of documents containing an upinterval that starts before 2017-01-05 and within each document I want to count the number of downintervals:

query={
aggs: {
filtered: {
filter:{ range: { "upinterval.start": { lte: "2017-01-05" }, _name: "avail1" } }
},
aggs:{
nested: {
path: "downinterval"
},
aggs: {
unavail_count: {
cardinality: {
field: "downinterval.id"
}
}
}
}
}
}

I pretend to even filter downintervals but I decided to attack a simpler problem.
Thanks for any help


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.