【发布时间】:2023-04-08 21:40:01
【问题描述】:
我已经成功地进行了一些 _bulk 插入,现在我正在尝试使用日期范围进行查询并过滤如下内容:
{
"query": {
"bool": {
"must": [{
"terms": {
"mt_id": [613]
}
},
{
"range": {
"time": {
"gt": 1470009600000,
"lt": 1470009600000
}
}
}]
}
}
不幸的是我没有得到结果,现在我注意到索引映射是在批量插入之后创建的,如下所示:
{
"agg__ex_2016_8_3": {
"mappings": {
"player": {
"properties": {
"adLoad": {
"type": "long"
},
"mt_id": {
"type": "long"
},
"time": {
"type": "string"
}
}
},
作为一种解决方案,我尝试使用以下方法更改索引映射:
PUT /agg__ex_2016_8_3/_mapping/player
{
"properties" : {
"mt_id" : {
"type" : "long",
"index": "not_analyzed"
}
}
}
得到
{
"acknowledged": true
}
和 PUT /agg__ex_2016_8_3/_mapping/player
{
"properties" : {
"time" : {
"type" : "date",
"format" : "yyyy/MM/dd HH:mm:ss"
}
}
}
得到:
{
"error": {
"root_cause": [
{
"type": "remote_transport_exception",
"reason": "[vj_es_c1-esc13][10.132.69.145:9300][indices:admin/mapping/put]"
}
],
"type": "illegal_argument_exception",
"reason": "mapper [time] of different type, current_type [string], merged_type [date]"
},
"status": 400
}
但是什么也没发生,仍然没有得到任何结果。
我做错了什么? (我必须使用 http,而不是 curl)
谢谢!!
【问题讨论】:
-
time字符串类型的字段不太好。你能展示一个你认为应该匹配的示例文档吗? -
Val: ,我已编辑问题文档:{ "_index": "agg__ex_2016_8_2", "_type": "player", "_id": "104", "_score": 4.244597, “_source”:{“时间”:“1470009600000”,“域”:“organisemyhouse.com”,“master_domain”:“613###organisemyhouse.com”,“playerRequets”:4,“playerLoads”:0“c_Id ": 0, "cb_Id": 0, "mt_Id": 613 } },
标签: elasticsearch indexing lucene elasticsearch-plugin sense