当我这样查询数据集时:
curl -X GET "localhost:9200/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"range" : {
"time_written" : {
"gte": "2009-01-01",
"lte": "2011-01-01",
"format": "yyyy-MM-dd"
}
}
}
}
'
我用time_writing 2010-10-12找到了结果
但是使用此查询:
curl -X GET "localhost:9200/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"range" : {
"time_written" : {
"gte": "2010-01-01",
"lte": "2011-01-01",
"format": "yyyy-MM-dd"
}
}
}
}
'
找不到带有time_writing 2010-10-12的结果。知道为什么会这样吗?
更新
映射:
{
"textobject-index":{
"mappings":{
"doc":{
"properties":{
"main_text":{
"type":"text",
"fielddata":true
},
"time_written":{
"type":"text",
"fielddata":true
},
"translated_text":{
"type":"text",
"fielddata":true
}
}
}
}
}
}
结果示例:
{
"took":1,
"timed_out":false,
"_shards":{
"total":5,
"successful":5,
"skipped":0,
"failed":0},
"hits":{
"total":1,
"max_score":1.0,
"hits":[{
"_index":"textobject-index",
"_type":"doc",
"_id":"10",
"_score":1.0,
"_source":{
"main_text":"some long text",
"time_written":"2010-10-12"
}
}]
}
}