我知道这可以作为过滤器来完成,但是出于“原因”,我需要将其作为Lucene查询执行。
我有一个名为“FileLoadedToElasticDateTime”的字段,我正在尝试查找今年的任何记录,到目前为止,我得到的结果为零。
我努力了:
FileLoadedToElasticDateTime:[2018-01-01 TO 2018-12-31]
FileLoadedToElasticDateTime:[20180101 TO 20181231]
FileLoadedToElasticDateTime:[2018-01-01T00:00:00 TO 2018-12-31T18:00:00]
FileLoadedToElasticDateTime:[2018-01-01 00:00:00 TO 2018-12-31 18:00:00] <-- Error
这是该字段的文档 View :
ES映射格式为yyyy-MM-dd hh:mm:ss,我不确定是否可以使用kibana格式吗?
任何帮助将不胜感激。
这也是我尝试使用时间格式的错误
Error: Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"query_shard_exception","reason":"Failed to parse query [FileLoadedToElasticDateTime:[2018-01-01 00:00:00 TO 2018-12-31 18:00:00]]","index_uuid":"HRAubcpVQM2Zk2oUVqN7Ng","index":"analytical"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"analytical","node":"Rb3ZRLUYTk-WmEEUOh4tdQ","reason":{"type":"query_shard_exception","reason":"Failed to parse query [FileLoadedToElasticDateTime:[2018-01-01 00:00:00 TO 2018-12-31 18:00:00]]","index_uuid":"HRAubcpVQM2Zk2oUVqN7Ng","index":"analytical","caused_by":{"type":"parse_exception","reason":"Cannot parse 'FileLoadedToElasticDateTime:[2018-01-01 00:00:00 TO 2018-12-31 18:00:00]': Encountered \" <RANGE_GOOP> \"00:00:00 \"\" at line 1, column 40.\nWas expecting:\n \"TO\" ...\n ","caused_by":{"type":"parse_exception","reason":"Encountered \" <RANGE_GOOP> \"00:00:00 \"\" at line 1, column 40.\nWas expecting:\n \"TO\" ...\n "}}}}]},"status":400}
我试过用引号将日期引起来,但这也不起作用。
我没有其他查询错误,只有零结果
最佳答案
您需要在日期和时间部分之间放置T
符号。
像这样:
FileLoadedToElasticDateTime:[2018-01-01T00:00:00 TO 2018-12-31T18:00:00]
有关日期格式的更多信息-https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html
关于elasticsearch - Kibana Lucene日期范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50478156/