如何使用 Python 更新 Elastic Search 并理解模式?

问题描述

我正在尝试使用 es-python 的这种方法为 ES 的现有索引创建键和值

from elasticsearch import Elasticsearch
elastic.update(index='cities',doc_type=doc_type,id=1,body={'doc':{'city':{'username':'Tom'}},'doc_as_upsert':True})

但是出现错误可能是我无法正确理解映射/架构或其他什么,因为我在 1 天前刚刚开始在紧急情况下使用它。

分享您对此的看法。映射是这样的..

get_mapping() response type: <class 'dict'>

_mapping keys(): dict_keys(['properties'])
doc_type: properties
{
    "city": {
        "type": "text","fields": {
            "keyword": {
                "type": "keyword","ignore_above": 256
            }
        }
    },"country": {
        "type": "text","ignore_above": 256
            }
        }
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)