gpt4 book ai didi

Elasticsearch 索引类型在更新状态后没有改变

转载 作者:行者123 更新时间:2023-12-03 01:53:03 25 4
gpt4 key购买 nike

我已经成功地进行了一些 _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)

谢谢!!

最佳答案

试试这个:

# 1. delete index
DELETE agg__ex_2016_8_3

# 2. recreate it with the proper mapping
PUT agg__ex_2016_8_3
{
"mappings": {
"player": {
"properties": {
"adLoad": {
"type": "long"
},
"mt_id": {
"type": "long"
},
"time": {
"type": "date"
}
}
}
}
}

# 3. create doc
PUT agg__ex_2016_8_3/player/104
{
"time": "1470009600000",
"domain": "organisemyhouse.com",
"master_domain": "613###organisemyhouse.com",
"playerRequets": 4,
"playerLoads": 0,
"c_Id": 0,
"cb_Id": 0,
"mt_Id": 613
}

# 4. search
POST agg__ex_2016_8_3/_search
{
"query": {
"bool": {
"must": [
{
"terms": {
"mt_Id": [
613
]
}
},
{
"range": {
"time": {
"gte": 1470009600000,
"lte": 1470009600000
}
}
}
]
}
}
}

关于Elasticsearch 索引类型在更新状态后没有改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38759159/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com