2016-02-01 7 views
18

Perdonatemi se questo è piuttosto semplice, ma ho Python 2.7 e elasticsearch 2.1.1 e sto solo cercando di eliminare un indice utilizzandoelasticsearch: Come eliminare un indice utilizzando pitone

es.delete(index='researchtest', doc_type='test') 

ma questo mi dà

return func(*args, params=params, **kwargs) 
TypeError: delete() takes at least 4 arguments (4 given) 

ho anche provato

es.delete_by_query(index='researchtest', doc_type='test',body='{"query":{"match_all":{}}}') 

ma ho

AttributeError: 'Elasticsearch' object has no attribute 'delete_by_query' 

Qualche idea sul perché? L'API è cambiato per 2.1.1 per python?

https://elasticsearch-py.readthedocs.org/en/master/api.html#elasticsearch.client.IndicesClient.delete

risposta

30

Dalla documentazione, utilizzare questa notazione:

from elasticsearch import Elasticsearch 
es = Elasticsearch() 

es.indices.delete(index='test-index', ignore=[400, 404]) 
+2

grazie! proprio quello di cui avevo bisogno – AbtPst