python-3.x - 如何在 elasticsearch python 客户端的 es.index 中设置映射?
问题描述
我有 json 格式的 twitter 数据,我必须使用弹性搜索对其进行索引。我还必须为数据指定映射。
es = Elasticsearch([{'host': 'localhost', 'port': 9200}])
mapping='''{"mappings": {"_doc": {"properties":.......'''
for i,record in enumerate(data):
es.index(index='index', doc_type='tweet', id=i, body=record)
我应该在哪里指定我的映射?
我读到我可以指定映射es.indices.create
es.indices.create(.......,body=mapping)
但是然后我如何输入我的记录数据?es.indices.create、es.index 和 es.create 有什么区别?
解决方案
推荐阅读
- python - Django:如何通过模板更改模型变量值
- javascript - 如何让一个函数在 JavaScript 中返回一个 Promise?
- python - 电报 bot.polling() 上的 socket.timeout
- docker - 我的 docker 映像中复制文件的不同 SHA1(来自 Maven Build)
- c++ - 为什么 Shell_NotifyIcon 不显示气球通知?
- c - VS Code 在 settings.json 中插入错误的 make 和 gdb 路径
- kubernetes - 使用 kubernetes 服务对代理地址进行 DNS 解析时无法路由到外部 http 代理
- angular - Azure Dev Ops 将 Angular 应用程序部署到静态 Web 应用程序
- java - 如何指定我的路径以便 Eclipse 找到它?
- java - 如何在 Elasticsearch 中查找和标记重复项