【发布时间】:2016-05-21 03:08:16
【问题描述】:
我无法使用弹性搜索日期格式进行搜索
我创建了一个索引,字段映射显示为日期格式,但查询失败。
在加载数据之前,我创建了一个带有映射的索引并将我的数据加载到弹性搜索中。
"mappings": {
"workers": {
"person.birthDate": {
"full_name": "person.birthDate",
"mapping": {
"birthDate": {
"type": "date",
"format": "yyyy-MM-dd||epoch_millis"
}
}
}
我的输入查询如下
POST _search
{
"query": {
"bool" : {
"must" : [ {
"match" : {
"person.birthDate" : {
"query" : "1968-06-15",
"type" : "date"
}
}
} ]
}
},
"from": 0,
"size": 10,
"sort": [],
"aggs": {}
}
输出是
{
"error": {
"root_cause": [
{
"type": "query_parsing_exception",
"reason": "[match] query does not support type date",
"index": "index1",
"line": 9,
"col": 33
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "index1",
"node": "RewaFar_TsGVGz1RmgOxlA",
"reason": {
"type": "query_parsing_exception",
"reason": "[match] query does not support type date",
"index": "index1",
"line": 9,
"col": 33
}
}
]
},
"status": 400
}
对此的任何帮助将不胜感激。 请注意,我对弹性搜索非常陌生。
【问题讨论】:
标签: elasticsearch