Elasticsearch
Python elasticsearch is the Official low-level client for Elasticsearch. Its goal is to provide common ground for all Elasticsearch-related code in Python; because of this it tries to be opinion-free and very extendable.
Installation⚑
pip install elasticsearch
Usage⚑
Connect to the database⚑
from elasticsearch import Elasticsearch
client = Elasticsearch("http://localhost:9200")
Get all indices⚑
client.indices.get(index="*")
Get all documents⚑
resp = client.search(index="test-index", query={"match_all": {}})
documents = resp.body["hits"]["hits"]
Use pprint
to analyze the content of each document
.
Update a document⚑
doc = {"partial_document": "value"}
resp = client.update(index=INDEX, id=id_, doc=doc)