2017-03-02 84 views
0

我想從索引中刪除基於Id的特定文檔。在探索過程中,我發現delete_by_query已被棄用,但現在已回到版本5.1等。有人能指導我如何以及在哪裏可以在圖書館找到它。我使用的彈性搜索5.1.2版彈性搜索delete_by_query使用elasticsearch-dsl

回答

0

下面是一個例子 -

from elasticsearch import Elasticsearch 

es = Elasticsearch([{'host': 'localhost', 'port': 9200}]) //your hostname here 

es.index(index='your_index_here', doc_type='data', id=id_, body=data_json) 

es.delete(index='your_index_here',doc_type='data',id=id_) 

pip install elasticsearch將安裝在蟒蛇Python API中假設你有點子。

+0

這可能會實現。沒試過。找到了替代解決方案。謝謝你的幫助。 – Aayushi

0

我想我不需要delete_by_query。它可以使用DocType完成。 下面是代碼:

doc = DocType(Mdm) 
    doc.delete(id=1)