elasticsearch elasticesearch添加关键字不工作

46qrfjad  于 2023-03-01  发布在  ElasticSearch
关注(0)|答案(1)|浏览(141)

错误:

{"timestamp": "2023-02-26T16:06:23.388759Z", "level": "INFO", "name": "denali_syncer.opensearch",
    "message": "create index cd.io.schema.asset mapping, status 400, body: b'{\"error\":{\"root_cause\":[{\"type\":
    \"mapper_parsing_exception\",\"reason\":\"Failed to parse mapping [_doc]: mapper [metadata.cloudAccountId] cannot 
    be changed from type [text] to [ObjectMapper]\"}],\"type\":\"mapper_parsing_exception\",\"reason\":\"Failed to parse
    mapping [_doc]: mapper [metadata.cloudAccountId] cannot be changed from type [text] to [ObjectMapper]\",\
    \"caused_by\":{\"type\":\"illegal_argument_exception\",\"reason\":\"mapper [metadata.cloudAccountId] cannot be changed from type [text] 
    to [ObjectMapper]\"}},\"status\":400}'"}

用于索引Map的数据

{
    "cloudAccountId" : {"type" : "text"},
    "cloudAccountId.keyword" : {"type" : "keyword"},
}

代码:

url = f'{OPENSEARCH_URL}/{dataset}'
response = requests.post(url=url, headers=HEADERS, data=fields_json)

我正在使用上面的代码来创建索引,并使用关键字排序,我得到以上错误
请检查如何处理此情况

eagi6jfj

eagi6jfj1#

要正常工作,索引Map应该如下所示:

{
    "cloudAccountId" : {
       "type" : "text",
       "fields": {
         "keyword": { "type": "keyword" }
       }
    }
}

相关问题