elasticsearch5.5.2环境搭建
運(yùn)行elasticsearch5.5.2需要jdk1.8版本以上
1.elasticsearch可以去官網(wǎng)或github下載,window系統(tǒng)推薦zip壓縮版
2.解壓后 進(jìn)入bin目錄運(yùn)行elasticsearch.bat啟動(dòng)服務(wù)
3.訪問localhost:9500測試是否成功
4.安裝中文分詞插件:https://github.com/medcl/elasticsearch-analysis-ik上下載對應(yīng)elasticsearch版本的ik分詞器
5.停止elasticsearch服務(wù),解壓分詞器放入elasticsearch安裝目錄下的plugins目錄中
6.重啟elasticsearch服務(wù)器,看到加載ik插件表示安裝分詞插件成功。
7.安裝Kibana方便用于elasticsearch交互,訪問官網(wǎng)下載,推薦下載zip壓縮版,與elasticsearch版本要對應(yīng)
8.解壓,進(jìn)入bin目錄 window下執(zhí)行kibaba.bat啟動(dòng)kibaba服務(wù)。
9.訪問localhost:5601測試是否成功
以上1-7步完成基本上可以開始與項(xiàng)目整合開發(fā)了
下面是一些常用請求:
GET localhost:9200 獲取當(dāng)前當(dāng)前節(jié)點(diǎn)、集群、版本等信息
GET localhost:9200/_cat/indices?v 查看當(dāng)前節(jié)點(diǎn)的所有Index
GET localhost:9200/_mapping?pretty=true 列出每個(gè)Index所包含的Type(建立索引時(shí)的mapping結(jié)構(gòu))
PUT localhost:9200/weather 新建一個(gè)名字為weather的Index
DELETE localhost:9200/weather 刪除名字為weather的Index
PUT localhost:9200/weather
{"mappings": {"typeName": {"properties": {"title": {"type": "text","analyzer": "ik_max_word"},"desc": {"type": "text","analyzer": "ik_max_word"}}}}
}
新建Index時(shí)候也可以同時(shí)發(fā)送一個(gè)mappings,用于映射Index的Type屬性結(jié)構(gòu)
PUT localhost:9200/weather/beijing/1
{
"title":"1月份天氣",
"desc":"陽光很好"
}
給weather索引的beijing類型(即Document的分組)新增一條id為1的文檔 POST localhost:9200/weather/beijing
{ "title":"2月份天氣",
"desc":"陰天" }
新增記錄的時(shí)候也可以不指定id,請求方式要改成POST
注意,如果沒有先創(chuàng)建 Index(這個(gè)例子是weather),直接執(zhí)行上面的新增命令,Elastic 也不會(huì)報(bào)錯(cuò),而是直接生成指定的 Index。
GET localhost:9200/weather/beijing/1?pretty=true 查看id為1的這條記錄,pretty=true表示以已讀的形式返回
DELETE localhost:9200/weather/beijing/1 刪除id為1的記錄
PUT localhost:9200/weather/beijing/1
{"title" : "3月份天氣","desc" : "晴轉(zhuǎn)多云"
}
更新id為1的這條記錄
GET localhost:9200/weather/beijing/_search 查詢weather索引的beijing類型的所有文檔
GET localhost:9200/weather/beijing/_search
{"query" : { "match" : { "desc" : "多云 晴" }} }
全文檢索weather索引的beijing類型中文檔的desc屬性值匹配“多云” or “晴”這個(gè)詞的前10條記錄
GET localhost:9200/accounts/person/_search
{"query": {"bool": {"must": [{ "match": { "desc": "多云" } },{ "match": { "desc": "晴" } }]}}
}
布爾查詢
參考:http://www.ruanyifeng.com/blog/2017/08/elasticsearch.html 全文搜索引擎 Elasticsearch 入門教程 https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html Elasticsearch: 官方參考文檔
https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.html Elasticsearch: 權(quán)威指南 http://www.bayescafe.com/database/elasticsearch-using-index-or-type.html ElasticSearch: Index 和 Type 的區(qū)別
https://github.com/medcl/elasticsearch-analysis-ik elasticsearch-analysis-ik
http://hao.jobbole.com/kibana/ Kibana:分析及可視化日志文件 Elasticsearch+Logstash+Kibana教程
https://www.elastic.co/guide/en/kibana/current/index.html KIbana使用指南
http://www.cnblogs.com/xing901022/p/4704319.html
http://www.jianshu.com/p/40b7fbc924b1 elasticsearch 5.4 JAVA API 使用
http://blog.csdn.net/ljc2008110/article/details/48652937 ElasticSearch的Java API
http://www.jianshu.com/p/b46587445c1c Elasticsearch java api 概述
https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport-client.html Transport Client官方文檔
? ? ? ? ? ? ? ?
轉(zhuǎn)載于:https://www.cnblogs.com/hihtml5/p/7497518.html
總結(jié)
以上是生活随笔為你收集整理的elasticsearch5.5.2环境搭建的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 洛谷P3572 [POI2014]PTA
- 下一篇: 开一家蛋糕店,要多少资金啊?