困っていること
Elasticsearch7で下記のようdata_range bucketsの定義をしたのですが、
以下のようなエラーが出てしまいます。
解決方法をご教授願えないでしょうか?
data_range bucketsのクエリ記法
curl -XGET'http://localhost:9200/niziu/_search?pretty' -H 'Content-Type:application/json' -d' > { "aggs": { "genre": { "date_range": { "field": "date" , "format":"yyyy-MM-dd" , "ranges":[{ "from":"Now-1y" ,"to":"Now" }] }}}}'
エラー内容
{ "error" : { "root_cause" : [ { "type" : "parse_exception", "reason" : "failed to parse date field [Now-1y] with format [yyyy-MM-dd]: [failed to parse date field [Now-1y] with format [yyyy-MM-dd]]" } ], "type" : "search_phase_execution_exception", "reason" : "all shards failed", "phase" : "query", "grouped" : true, "failed_shards" : [ { "shard" : 0, "index" : "niziu", "node" : "blesSRiaRTW6xRf_O8_jNg", "reason" : { "type" : "parse_exception", "reason" : "failed to parse date field [Now-1y] with format [yyyy-MM-dd]: [failed to parse date field [Now-1y] with format [yyyy-MM-dd]]", "caused_by" : { "type" : "illegal_argument_exception", "reason" : "failed to parse date field [Now-1y] with format [yyyy-MM-dd]", "caused_by" : { "type" : "date_time_parse_exception", "reason" : "Text 'Now-1y' could not be parsed at index 0" } } } } ] }, "status" : 400 }
試したこと1
format関連でエラーが発生しているようだったので
'Now-1y'を'Now-1M'に範囲を変えてみたが、エラー内容に変化はなかった
試したこと2
同じくformat関連でエラーが発生しているようだったので
クエリ記法で「"format":"yyyy-MM-dd" , 」を抜いてみたが
以下のようなエラーが発生した
{ "error" : { "root_cause" : [ { "type" : "parse_exception", "reason" : "failed to parse date field [Now-1y] with format [strict_date_optional_time||epoch_millis]: [failed to parse date field [Now-1y] with format [strict_date_optional_time||epoch_millis]]" } ], "type" : "search_phase_execution_exception", "reason" : "all shards failed", "phase" : "query", "grouped" : true, "failed_shards" : [ { "shard" : 0, "index" : "niziu", "node" : "blesSRiaRTW6xRf_O8_jNg", "reason" : { "type" : "parse_exception", "reason" : "failed to parse date field [Now-1y] with format [strict_date_optional_time||epoch_millis]: [failed to parse date field [Now-1y] with format [strict_date_optional_time||epoch_millis]]", "caused_by" : { "type" : "illegal_argument_exception", "reason" : "failed to parse date field [Now-1y] with format [strict_date_optional_time||epoch_millis]", "caused_by" : { "type" : "date_time_parse_exception", "reason" : "Failed to parse with all enclosed parsers" } } } } ] }, "status" : 400 }
データの中身
{"index":{"_index":"niziu","_type":"_doc"}} { "name": "山口 真子" , "date": "2020-12-24", "genre": "st1" , "price": "10" } {"index":{"_index":"niziu","_type":"_doc"}} { "name": "花橋 梨緒" , "date": "2020-12-23", "genre": "st1" , "price": "100" } {"index":{"_index":"niziu","_type":"_doc"}} { "name": "勝村 摩耶" , "date": "2020-12-23", "genre": "st2" , "price": "50" }
補足情報(FW/ツールのバージョンなど)
CentOS8
Elasticsearch7.10
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/01/18 06:46