Created
April 4, 2020 03:03
-
-
Save toravir/7706d662a697f9943adf5252d81370a2 to your computer and use it in GitHub Desktop.
Python Client For Elasticsearch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from elasticsearch import Elasticsearch | |
indexName='tstidx1' | |
es = Elasticsearch([{'host':'sprint.cisco.com', 'port':9200}]) | |
es.info() | |
indexBody= { | |
"settings" : { | |
"number_of_shards": 1, | |
"number_of_replicas" : 0 | |
} | |
} | |
if not es.indices.exists(indexName): | |
es.indices.create(index=indexName, body=indexBody) | |
docBody = { "foo" : "bar", "price" : 100} | |
es.create(id=100, index=indexName, doc_type='people', body=docBody) | |
print (es.get(index=indexName, doc_type='people', id=100)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment