elasticsearch - Kibana Lucene日期范围

标签 elasticsearch lucene kibana

我知道这可以作为过滤器来完成,但是出于“原因”,我需要将其作为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 :

enter image description here

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/

相关文章:

java - 使用 SolR 的不同类型术语构建查询

elasticsearch - 返回与多个通配符字符串查询匹配的文档

elasticsearch - 似乎无法将Docker容器端口公开给主机

elasticsearch - 是否可以限制 Elasticsearch 索引的大小?

search - 如何在 Solr Dismax 查询中正确提升结果

java - 在 Lucene 中编写 Tokenizer 的正确方法

elasticsearch - 安装 ElasticSearch APM

lucene - 是否可以对Kibana/Lucene查询进行简单的演算?

json - 在couchdb中使用elasticsearch索引json中的名称

elasticsearch - 如何在Elasticsearch的POST请求正文中指定要索引的2个或更多文档?