Elasticsearch 入門(一)

零、 Basic Concept

Elasticsearch 是基于Lucene 的搜索引擎。Lucene 是一個(gè)強(qiáng)大的開源搜索庫。它倆關(guān)系就像是汽車 跟引擎的關(guān)系。Elasticsearch 是一個(gè)實(shí)時(shí)的分布式搜索分析引擎,被用作全文檢索、結(jié)構(gòu)化搜索、分析以及這三個(gè)功能的組合。官方定義:

Elasticsearch is a distributed, RESTful search and analytics engine capable of solving a growing number of use cases. As the heart of the Elastic Stack, it centrally stores your data so you can discover the expected and uncover the unexpected.

一、Install Elasticsearch on MacOS

  • 安裝java ,oracle官網(wǎng)安裝,確認(rèn)安裝成功。
  $ java --version  
  • brew 安裝Elasticsearch
$ brew update
$ brew install elasticsearch 
$ brew info elasticsearch

二、Try it out

$ elasticsearch
chrome plugin: json viewer

一個(gè) Elasticsearch 請求和任何 HTTP 請求一樣由若干相同的部件組成:

$curl -X<VERB> '<PROTOCOL>://<HOST>:<PORT>/<PATH>?<QUERY_STRING>' -d '<BODY>'

Elasticsearch HTTP 服務(wù)的端口號,默認(rèn)是 9200.
PATH是API 的終端路徑(例如 _count 將返回集群中文檔數(shù)量)。
QUERY_STRING 是任意可選的查詢字符串參數(shù)
BODY是一個(gè) JSON 格式的請求體 (如果請求需要的話)

三、CRUD

新增記錄

$curl -X POST 'localhost:9200/accounts/post' -d'{ "title":"elasticsearch","content":"hello, elasticsearch2","tag":"elasticsarch2"}'

修改記錄

$curl -X PUT 'localhost:9200/accounts/post/1' -d'{ "title":"elasticsearch","content":"update, elasticsearch","tag":"updated"}'

刪除記錄

$curl -X DELETE '127.0.0.1:9200/accounts/post/1'

四、參考鏈接

[ElasticSearch 官方網(wǎng)站](https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started.html

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容