Elasticsearch7.x help for windows
安裝
1、下載 解壓 運行 ./bin/elasticsearch.bat
2密幔、http://localhost:9200/ 顯示如下表示安裝成功
{
"name" : "node-wikidata",
"cluster_name" : "cluster-wikidata",
"cluster_uuid" : "5swHCzTaSTe6j5WO9_8Wew",
"version" : {
"number" : "7.9.3",
"build_flavor" : "default",
"build_type" : "zip",
"build_hash" : "c4138e51121ef06a6404866cddc601906fe5c868",
"build_date" : "2020-10-16T10:36:16.141335Z",
"build_snapshot" : false,
"lucene_version" : "8.6.2",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
交互工具kibana安裝
1鬓长、下載 解壓 運行 ./bin/kibana.bat
(可選(查詢數(shù)據(jù)略方便))Elasticsearch-head 插件安裝
依賴環(huán)境node和grunt
1臣咖、安裝node(跳過安裝步驟(一直 next))
2踏幻、安裝grunt
npm install -g grunt -cli
3控硼、準(zhǔn)備
進(jìn)入 elasticsearch-7.x/config
修改elasticsearch.yml
泽论,末尾添加
# 不限制IP訪問
network.host: 0.0.0.0
# 必須和host一起配置,否則報錯
http.port: 9200
# 允許跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
4卡乾、安裝head插件
官網(wǎng)下載 https://github.com/mobz/elasticsearch-head 下載zip
解壓 進(jìn)入 elasticsearch-head-master
修改 Gruntfile.js
添加如下內(nèi)容
986140-20180227095130174-1314908435.png
npm install
# 安裝完成后
npm run start
# 或 grunt server
image-20201028221214647.png
5翼悴、訪問 http://localhost:9100/
image-20201028221445741.png
以下操作均在kibana dev tool中完成 數(shù)據(jù)以wikidata抽取的三元組為例
(基本操作”查插刪改“請在百度中自學(xué))
查看索引
w - 索引名
GET /w/_mapping
建立索引 (ES 7.x 不能再在“mappings”下制定索引名)
PUT w
{
"mappings": {
"properties": {
"label": {
"type": "keyword"
},
"alias": {
"type": "keyword"
},
"desc": {
"type": "text"
},
"prop": {
"type": "nested",
"properties": {
"pred": {
"type": "keyword"
},
"obj": {
"type": "keyword"
}
}
}
}
}
}
之所以每一對(屬性名,屬性值)存儲為一個object幔妨,并放入一個list中鹦赎,是因為這是elasticsearch定義的一種nested object的數(shù)據(jù)類型, 這種數(shù)據(jù)類型能存儲大量擁有相同的key的對象误堡,并且可以對之進(jìn)行有效的檢索古话。這樣,不論數(shù)據(jù)集中有多少種種類不同的屬性锁施,都 可以以相同的格式存儲陪踩。1
查 屬性名=話題主分類, 值=Category:Groningen (city) 的實體2
不分詞 (keyword 類型 關(guān)鍵字 不會被分詞悉抵, text 普通文本 會被分詞)
GET /w/_search
{
"query": {
"bool": {
"must": [
{
"nested": {
"path": "prop",
"query": {
"bool": {
"must": [
{
"match": {
"prop.pred": "話題主分類"
}
},
{
"match": {
"prop.obj": "Category:Groningen (city)"
}
}
]
}
}
}
}
]
}
}
}
參考文獻(xiàn)
??
-
[1] 索引模型
??