-
安裝 Elasticserach:
下載最新的elasticsearch:官網(wǎng)地址: https://www.elastic.co/downloads/elasticsearch
解壓縮之后,把 elasticsearch-<version>/bin 路徑放到 bash_profile 里
-
運(yùn)行
elasticsearch -
用命令行測(cè)試
curl 'http://localhost:9200/'應(yīng)給得到類似下面的響應(yīng):
{ "name" : "VJ6rpak", "cluster_name" : "elasticsearch", "cluster_uuid" : "enuYtqaGTaqoSYwErlyZBw", "version" : { "number" : "6.2.4", "build_hash" : "ccec39f", "build_date" : "2018-04-12T20:37:28.497551Z", "build_snapshot" : false, "lucene_version" : "7.2.1", "minimum_wire_compatibility_version" : "5.6.0", "minimum_index_compatibility_version" : "5.0.0" }, "tagline" : "You Know, for Search" }
-
安裝圖形界面kibana
下載kibana:官網(wǎng)地址: https://www.elastic.co/downloads/kibana
解壓縮之后,把 kibana-<version>/bin 路徑放到 bash_profile 里
中文版教程中還有安裝 sense 的步驟,但 Kibana 從 5.0.1 版本開(kāi)始就已經(jīng)自帶了調(diào)試工具,可以在 kibana 左側(cè)工具欄 DevTools 中找到。
-
啟動(dòng)kibana
kibana 用瀏覽器訪問(wèn)圖形界面:http://localhost:5601
-
Hello World
-
在 DevTools 查詢集群中文檔總數(shù)量
GET /_count { "query":{ "match_all":{} } } -
返回:
{ "count": 1, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 } }
-
-
Python 插件 elasticsearch
-
安裝elasticsearch
pip3 install elasticsearch -
hello world
from elasticsearch import Elasticsearch import pprint es = Elasticsearch() doc = { "query":{ "match_all":{} } } res = es.search(body=doc) pprint.pprint(res) -
應(yīng)該得到下面的結(jié)果:
{'_shards': {'failed': 0, 'skipped': 0, 'successful': 5, 'total': 5}, 'hits': {'hits': [{'_id': '1', '_index': 'test-index', '_score': 1.0, '_source': {'author': 'kimchy', 'text': 'Elasticsearch: cool. bonsai cool.', 'timestamp': '2018-05-10T10:24:58.396432'}, '_type': 'tweet'}], 'max_score': 1.0, 'total': 1}, 'timed_out': False, 'took': 1}
-
我的部分技術(shù)博客將會(huì)同步至騰訊云+社區(qū),邀請(qǐng)大家一同入駐:https://cloud.tencent.com/developer/support-plan?invite_code=3hp099lflrokw