Hello world,
I have an issue with using "missing" agg on nested documents.
An example to reproduce the problem :
Mapping :
POST /mli_test2 {
"mappings": {
"participations": {
"properties": {
"participationProducts": {
"type": "nested",
"properties": {
"label": {
"type": "string"
},
"quantity": {
"type": "long"
}
}
}
}
}
}
}
Data :
POST /mli_test2/participations/1
{
"number": "xxxx"
}
POST /mli_test2/participations/2
{
"participationProducts": [
{
"label": "TEST_LABEL",
"quantity": 1
}
],
"number": "xxxx"
}
POST /mli_test2/participations/3
{
"participationProducts": [
{
"label": "TEST_LABEL",
"quantity": 1
}
]
}
POST /mli_test2/participations/4
{
"number": "xxxx"
}
POST /mli_test2/participations/5
{
"number": "xxxx"
}
Elasticsearch query :
POST /mli_test2/participations/_search?search_type=count
{
"aggs": {
"participationProducts_agg": {
"nested": {
"path": "participationProducts"
},
"aggs": {
"participationProducts_empty_agg": {
"missing": {
"field": "participationProducts"
}
},
"label_agg": {
"terms": {
"field": "participationProducts.label"
},
"aggs": {
"participationProducts_agg": {
"sum": {
"field": "participationProducts.quantity"
}
}
}
}
}
},
"number_agg": {
"terms": {
"size": 1000,
"field": "number"
}
},
"number_empty_agg": {
"missing": {
"field": "number"
}
}
}
}
What we expect to retrieve from elasticsearch response :
- number = xxxx => 4 (participations 1,2,4,5)
- number_empty => 1 (participation 3)
- participationProducts = TEST_LABEL => 2 (participations 2,3)
- participationProducts_empty => 3 (participations 1,4,5)
But here is the result :
- number = xxxx => 4 OK
- number_empty => 1 OK
- participationProducts = TEST_LABEL => 2 OK
- participationProducts_empty => 3 KO
Thank you for your help