![](/img/trans.png)
[英]Not clear how to upsert ElasticSearch using python elasticsearch
[英]how to use python Elasticsearch client upsert api
我正在使用Elasticsearch python客户端作为http://elasticsearch-py.readthedocs.org/我努力但仍然找不到upup的更新api。 任何人都可以给我一个ES python客户端upx api的例子。
示例代码如下:
from elasticsearch import Elasticsearch
es = Elasticsearch("localhost:9200")
es.update(index='test',doc_type='test1',id='1',body={'doc':{'username':'Tom'},'doc_as_upsert':True})
如果没有doc_as_upsert=true
则在id不存在时会抛出异常。 此外,请确保您的数据包含在doc {}中。
方法index(*args, **kwargs)
在特定索引中添加或更新类型化的JSON文档,使其可搜索。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.