1
我正在處理一個ElasticSearch查詢,該查詢應該讓我回到所有文檔現在是1年前的日期字段,然後按月對它們進行分組(每個月給我總數),但是我沒有寫這個查詢。按月分組的ElasticSearch聚合信息
這是我有:
{
"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
}
我運行像這樣的查詢:
POST https://my-es-cluster-url.com
,但我不斷收到此錯誤:
{
"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
}
:因此,你應該嘗試使用? – Ibrahim