1. 程式人生 > >es啟動後配置步驟

es啟動後配置步驟

配置好ik分詞器後:

1.建立es索引: curl -XPUT localhost:9200/index   使用github上的命令,會報錯,自己修改了一下

2.建立mapping: 

curl -XPOST http://localhost:9200/index/fulltext/_mapping -H 'Content-Type:application/json' -d'

{

 "properties": {

 "content": {

"type": "text",

 "analyzer": "ik_max_word",

"search_analyzer": "ik_max_word"

 }

 }

}'

3.建立doc

curl -XPOST http://localhost:9200/index/fulltext/1 -H 'Content-Type:application/json' -d

'{"content":"中華人民共和國"}'

 

4. 開啟高亮

curl -XPOST http://localhost:9200/index/fulltext/_search  -H 'Content-Type:application/json' -d'

{

 "query" : { "match" : { "content" : "中華" }},

 "highlight" : {

"pre_tags" : ["<tag1>", "<tag2>"],

 "post_tags" : ["</tag1>", "</tag2>"],

 "fields" : {

 "content" : {}

}

 }

}'

 

elasticsearch-head是elastic search叢集的一個web前端。原始碼託管在github.com,地址是:https://github.com/mobz/elasticsearch-head。這是一個學習elasticsearch的利器。

安裝

有兩種方式來使用head。一種方式是作為ealsticsearch的外掛,另一種是將其作為一個獨立的webapp來執行。這裡將其作為elasticsearch外掛來使用。

線上安裝步驟:

離線安裝步驟:

 

操作到現在已經安裝好 es和ik,並且已經想index索引庫中加入了幾條資料,但這只是在控制檯操作,沒有在視覺化頁面操作,也沒有整合到專案中使用java業務來操作