pip install elasticsearch python from elasticsearch import Elasticsearch es = Elasticsearch(hosts=[{'host': 'localhost', 'port': 9200}]) python doc = {'title': 'example', 'content': 'This is an example document.'} es.index(index='my_index', doc_type='my_doc', id=1, body=doc) python query = {'query': {'match': {'title': 'example'}}} result = es.search(index='my_index', doc_type='my_doc', body=query) python query = {'aggs': {'avg_views': {'avg': {'field': 'views'}}}} result = es.search(index='my_index', doc_type='my_doc', body=query)


上一篇:
下一篇:
切换中文