Hello,
I'm trying to figure out if there's a way to query an index to retrieve the documents where field_A = field_B...
Using data from https://demo.elastic.co (kibana_sample_data_flights)
Sort of (in SQL):
select OriginWeather, count(*) from kibana_sample_data_flights where OriginWeather = DestWeather group by OriginWeather
My closest hypothesis so far is to build an aggregation like the following
(which comes from a kibana heat map).
But I don't know how to complete the following step to only get the values on the diagonal.
GET kibana_sample_data_flights/_search
{
"size": 0,
"_source": {
"excludes": []
},
"aggs": {
"2": {
"terms": {
"field": "DestWeather",
"size": 5,
"order": {
"_count": "desc"
}
},
"aggs": {
"3": {
"terms": {
"field": "OriginWeather",
"size": 5,
"order": {
"_count": "desc"
}
}
}
}
}
},
"stored_fields": [
"*"
],
"script_fields": {
"hour_of_day": {
"script": {
"inline": "doc['timestamp'].value.hourOfDay",
"lang": "painless"
}
}
},
"docvalue_fields": [
"timestamp"
],
"query": {
"match_all": {}
}
}
