es 安裝
官網(wǎng)下載
https://www.elastic.co/cn/downloads/elasticsearch
下載好后亩歹,進(jìn)入bin目錄下,執(zhí)行 ./elasticsearch
不報(bào)錯(cuò)新荤,啟動(dòng)成功之后揽趾,就可以訪問了http://localhost:9200/
但是頁面就會出現(xiàn)讓你輸入賬號密碼,如下圖
經(jīng)過搜索苛骨,需要修改配置 config/elasticsearch.yml
接下來就可以正常訪問啦@橄埂9赌拧!
es head安裝
下載地址 :https://github.com/mobz/elasticsearch-head
解壓之后進(jìn)行head文件夾下
cnpm run start
訪問http://localhost:9100/ 就可以了
記得在config/elasticsearch.yml 添加兩行
http.cors.enabled: true
http.cors.allow-origin: "*"
ES索引操作
創(chuàng)建不帶mapping的索引
PUT /索引名
創(chuàng)建索引設(shè)置索引及分片
PUT /索引名
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 0
}
}
創(chuàng)建mapping (類似于schema)
這里補(bǔ)充一下es的數(shù)據(jù)類型吧俐筋!
es數(shù)據(jù)類型
PUT 索引名
{
{
"mappings":{
"properties":{
"id":{"type":"keyword"},
"content":{"type":"text"}
}
}
}
}