python代码添加es中的指定数据:
from Elasticsearch import Elasticsearch
host = '0.0.0.0:9200'
es = Elasticsearch([host])
data_dict = {"name":"嘎嘎","sex":"男"}
es.delete_by_query(index='test_index', doc_type='_doc', body=query)
python代码删除es中的指定数据:
from Elasticsearch import Elasticsearch
host = '0.0.0.0:9200'
es = Elasticsearch([host])
query = {'query': {'match': {'name': '嘎嘎'}}}
es.delete_by_query(index='test_index', body=query)
注:若删除的时候使用下列语句:
es.delete_by_query(index='test_index', doc_type='_doc', body=query)
则会出现下列警告:不赞成在搜索请求中指定类型
经查询:https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html