Hi!
So we are trying the following:
POST /items/_search
{
"size": 0,
"aggs": {
"some-agg": {
"date_histogram": {
"field": "created_at",
"interval": "day",
"min_doc_count": 0
},
"aggs": {
"items": {
"filters": {
"filters": {
"foo": {
"term": {
"document_type": "foo"
}
},
"bar": {
"term": {
"document_type": "bar"
}
}
}
}
},
"bars_to_foos_rate": {
"bucket_script": {
"buckets_path": {
"foos": "items['foo']._count",
"bars": "items['bar']._count"
},
"script": "params.foos / params.bars"
}
}
}
}
}
}
This is giving us the following error:
Invalid path element [items['bar']._count] in path [items['bar']._count]
Looking at the 1st and 4th code blocks here make us think we are using the correct bucket path syntax
Especially since doing:
POST /items/_search
{
"size": 0,
"aggs": {
"some-agg": {
"date_histogram": {
"field": "created_at",
"interval": "day",
"min_doc_count": 0
},
"aggs": {
"items": {
"filters": {
"filters": {
"foo": {
"term": {
"document_type": "foo"
}
},
"bar": {
"term": {
"document_type": "bar"
}
}
}
}
}
}
}
}
}
Yields:
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 14,
"successful" : 14,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 10000,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
},
"aggregations" : {
"some-agg" : {
"buckets" : [
{
"key_as_string" : "2019-05-29T00:00:00.000Z",
"key" : 1559088000000,
"doc_count" : 7,
"items" : {
"buckets" : {
"bar" : {
"doc_count" : 0
},
"foo" : {
"doc_count" : 0
}
}
}
}
]
}
}
}
We're using Elasticsearch 7.1 on AWS
Any clues what we might be doing wrong?
Many thanks!