Json 范围查询在Elasticsearch中不返回结果
我正在尝试获取通过elasticsearch编制索引的文档的以下部分:Json 范围查询在Elasticsearch中不返回结果,json,elasticsearch,range-query,Json,elasticsearch,Range Query,我正在尝试获取通过elasticsearch编制索引的文档的以下部分: temporal: { begin: "2016-11-30T00:00:00", end: "2016-12-08T13:55:02" }, 我在CURL上使用的查询(因为我目前正在本地主机上测试查询)如下所示: curl -XGET 'localhost:9201/_search?pretty' -H 'Content-Type: application/json' -d' { "query": {
temporal: {
begin: "2016-11-30T00:00:00",
end: "2016-12-08T13:55:02"
},
我在CURL上使用的查询(因为我目前正在本地主机上测试查询)如下所示:
curl -XGET 'localhost:9201/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query": {
"range" : {
"timestamp" : {
"gte": "2015-01-01 00:00:00",
"lte": "now"
}
}
}
}
'
映射
temporal: {
properties: {
begin: {
type: "date"
},
end: {
type: "date"
}
}
}
但是上面提到的查询没有返回任何成功的点击,尽管它至少应该返回上面提到的文档。假设您想在发布时搜索(注意,我已经格式化了datetime输入),这就是时间戳-映射
{
"temporal" : {
"mappings" : {
"doc" : {
"properties" : {
"temporal" : {
"properties" : {
"begin" : {
"type" : "date",
"format" : "strict_date_optional_time||epoch_millis"
},
"end" : {
"type" : "date",
"format" : "strict_date_optional_time||epoch_millis"
}
}
}
}
}
}
}
}
索引/查询文档:
curl -XPOST localhost:9200/temporal/doc/1 -d '
{"temporal": {
"begin": "2016-11-30T00:00:00",
"end": "2016-12-08T13:55:02"
}}';
curl -XGET 'localhost:9200/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query": {
"range" : {
"temporal.begin" : {
"gte": "2015-01-01T00:00:00",
"lte": "now"
}
}
}
}'
{
"took" : 6,
"timed_out" : false,
"_shards" : {
"total" : 108,
"successful" : 108,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "temporal",
"_type" : "doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"temporal" : {
"begin" : "2016-11-30T00:00:00",
"end" : "2016-12-08T13:55:02"
}
}
} ]
}
}
您的文档顶部没有任何
时间戳
字段。@val我尝试将查询中的时间戳字段更改为临时字段,但仍然没有生成任何结果。您需要将其更改为临时字段。根据要检查的数据字段,开始
或临时字段。结束
。@val所以我想检查它temporal.begin,我相应地编辑了查询,但结果仍然不出来。您能显示您的映射吗curl-XGET localhost:9200/您的索引
?