python-2.7rallyelasticsearch-5pyral

Elasticsearch - find exists index patterns


I'm using Python script that fetch data from Rally API, manipulate it and send to Elasticsearch. I'm trying to figure how to find my exist index/s in script code. My ES instance is quite simple:

es = Elasticsearch([{'host': 'myIP', 'port': 9200}])

I cannot find where's exist index in this instance

My purpose is to state a condition for updating my index/s data

Any idea?

tnx


Solution

  • OK I found the solution and it's quite simple to use. Just type:

    from elasticsearch import Elasticsearch 
    
    es = Elasticsearch([{'host': 'host_ip', 'port': 9200}])
    
    if es.indices.exists(index = 'index_name') 
     #set a condition here