pip install elasticsearch
python
from elasticsearch import Elasticsearch
client = Elasticsearch(hosts=[{'host': 'localhost', 'port': 9200}])
python
client.indices.create(index='my_index')
python
client.indices.delete(index='my_index')
python
client.index(index='my_index', id=1, body={'title': 'Elasticsearch', 'content': 'Elasticsearch is a powerful search engine.'})
python
result = client.search(index='my_index', body={'query': {'match': {'content': 'search engine'}}})
python
result = client.search(index='my_index', body={'query': {'range': {'content': {'gte': 10, 'lte': 100}}}})
python
result = client.search(index='my_index', body={'aggs': {'group_by_content': {'terms': {'field': 'content.keyword'}}}})