I have an index with a single type and I want to run some aggregation queries on it; the mapping is here:
{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 2
}
},
"mappings": {
"v1": {
"_all": {"enabled": false},
"properties": {
"@timestamp": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis",
"index": true
},
"processingTime": {"type": "long", "index": false},
"batchSize": {"type": "long", "index": false},
"general": {
"type": "nested",
"properties": {
"total": {"type": "long"},
"migrated": {"type": "long"},
"joined": {"type": "long"},
"registered": {"type": "long"}
}
},
"scoped": {
"type": "nested",
"properties": {
"since": {"type": "long"},
"loggedIn": {"type": "long"},
"joined": {"type": "long"},
"registered": {"type": "long"}
}
}
}
}
}
}
Let's see my query; a simple date-histogram query to gather basic stats by minute :
{
"size": 0,
"aggs": {
"x": {
"date_histogram":{
"field": "@timestamp",
"interval": "minute"
},
"aggs": {
"stat-x": { "stats": {"field": "general.registered"}}
}
}
}
}
But when I run my query (the above one) I get null values as aggregated stats that I can't understand why!:
{
"_shards": {
"failed": 0,
"successful": 1,
"total": 1
},
"aggregations": {
"general": {
"doc_count": 2,
"max-x": {
"avg": null,
"count": 0,
"max": null,
"min": null,
"sum": null
}
}
},
"hits": {
"hits": [],
"max_score": 0.0,
"total": 2
},
"timed_out": false,
"took": 18
}
I don't have any idea why it's not working! mapping, types and query seem to be correct! Can anyone help me!