Hi,
I have followin use case for which I can't find an immediate solution right
now.
Use case:
I have a parent child relationship where parent represent a device and
child a module (eg. sensor) on a device. One device can have many modules
of a certain type, eg. 'motion', 'temperature',.... Parents are quite
static, but the module sends monitoring data on a regular basis to
elasticsearch. I need to find the modules (module types) that are not
responsive, ie. modules that did not send monitoring data between now and
now - t.
What I have:
With the query below, I can find devices where ALL of the modules are
unresponsive, but as soon as 1 module is responsive, even if the others are
unresponsive, the device is said to be responsive.
What I need:
I need to find the devices that have at least 1 module that is unresponsive.
Possible solution:
Aggregate on module types, then for each module type execute filter as
shown below AND give that module type to the has_parent -> has_child filter
as a 'and' construct with the range filter.
Is this possible as is or is there another way to solve this? Do I need to
create an issue to add this?
regards,
Sven
POST /devices-v1/module/_search?pretty=true
{
"size": 0,
"query": {
"filtered": {
"query": {
"match_all": {}
}
}
},
"aggs": {
"unresponsive": {
"filter": {
"and": [
{
"range": {
"_timestamp": {
"lt": "now-25m"
}
}
},
{
"not": {
"has_parent": {
"type": "device",
"filter": {
"has_child": {
"type": "module",
"filter": {
"range": {
"_timestamp": {
"gte": "now-25m"
}
}
}
}
}
}
}
}
]
},
"aggs": {
"modules": {
"terms": {
"script": "doc['_parent'].value + '|' +
doc['mod_id'].value ",
"size": 1000000000,
"order": {
"_term": "asc"
}
}
}
}
}
}
}
--
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/3e3f1074-c283-4a86-acfa-9d443bc5db02%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.