elasticsearch python API
生活随笔
收集整理的這篇文章主要介紹了
elasticsearch python API
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
yuanwen
Elasticsearch啟動(dòng)
# 進(jìn)入到elasticsearch的bin目錄 cd /.../.../elasticsearch-x.x.x/bin # 啟動(dòng)elasticsearch ./elasticsearch可以再開啟另外一個(gè)終端,輸入一下命令,測(cè)試是否啟動(dòng)成功
curl http://localhost:9200/ {"name" : "F37KLEk","cluster_name" : "elasticsearch","cluster_uuid" : "ZP1f4uWzRwyRCp0UElz9KA","version" : {"number" : "6.3.1","build_flavor" : "default","build_type" : "tar","build_hash" : "eb782d0","build_date" : "2018-06-29T21:59:26.107521Z","build_snapshot" : false,"lucene_version" : "7.3.1","minimum_wire_compatibility_version" : "5.6.0","minimum_index_compatibility_version" : "5.0.0"},"tagline" : "You Know, for Search" }在Python中操作Elasticsearch
安裝Elasticsearch模塊
查詢數(shù)據(jù)
from elasticsearch import Elasticsearches = Elasticsearch()# 獲取索引為my_index,文檔類型為test_type的所有數(shù)據(jù),result為一個(gè)字典類型 result = es.search(index="my_index",doc_type="test_type")# 或者這樣寫:搜索id=1的文檔 result = es.get(index="my_index",doc_type="test_type",id=1)# 打印所有數(shù)據(jù) for item in result["hits"]["hits"]:print(item["_source"]) form elasticsearch import Elasticsearches = Elasticsearch()# 刪除id=1的數(shù)據(jù) result = es.delete(index="my_index",doc_type="test_type",id=1)總結(jié)
以上是生活随笔為你收集整理的elasticsearch python API的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python elasticsearch
- 下一篇: python elasticsearch