Ich arbeite an einer ElasticSearch-Abfrage, die mir alle Dokumente zurückgeben sollte, wo ein Datumsfeld jetzt-1 Jahr ist und gruppieren sie alle nach Monat (geben mir Gesamtanzahl für jeden Monat), aber ich versage beim Schreiben dieser Abfrage.ElasticSearch Aggregat Informationen nach Monat gruppiert
Das ist, was ich habe:
{
"query": {
"bool": {
"must": [
{
"terms": {
"account_id": [
1
]
}
}
]
}
},
"aggs": {
"growth": {
"date_range": {
"field": "member_since",
"format": "YYYY-MM-DD",
"ranges": [
{
"to": "now-1Y/M"
},
{
"from": "now-1Y/M"
}
]
}
}
},
"size": 100
}
ich die Abfrage wie so leite:
POST https://my-es-cluster-url.com
, aber ich halte diesen Fehler:
{
"error": {
"root_cause": [
{
"type": "parse_exception",
"reason": "unit [Y] not supported for date math [-1Y/M]"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query_fetch",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "index0",
"node": "MkypXlGdQamAplca1JIgZQ",
"reason": {
"type": "parse_exception",
"reason": "unit [Y] not supported for date math [-1Y/M]"
}
}
]
},
"status": 400
}
, welche Version von ES verwenden Sie? – Ibrahim