#elastic 搭建 (本论坛)
#原先弄好的docker 搜索。莫名没了。container还被删了. 重搞一份。顺便做下记录.
#基于docker 创建elastic
docker run -d \
--name elasticsearch \
-e "ES_JAVA_OPTS=-Xms512m -Xmx512m" \
-e "discovery.type=single-node" \
-v /home/ubuntu/elastic/es-data:/usr/share/elasticsearch/data \
-v /home/ubuntu/elastic/es-logs:/usr/share/elasticsearch/logs \
--privileged \
-p 9200:9200 \
elasticsearch:7.17.7
#创建结构 表
curl -XPUT 127.0.0.1:9200/bbsgo_topic_1 -H 'Content-Type: application/json' -d'
{
"mappings": {
"properties": {
"id": {
"type": "long",
"store": true
},
"nodeId": {
"type": "long",
"store": true
},
"userId": {
"type": "long",
"store": true
},
"nickname": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
},
"title": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
},
"content": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
},
"tags": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"recommend": {
"type": "boolean"
},
"status": {
"type": "integer"
},
"createTime": {
"type": "long",
"store": true
}
}
}
}'
#安装插件。版本要对应
elasticsearch-analysis-ik-7.17.7.zip docker cp 到container 中。 进入容器 ./usr/share/elasticsearch/plugins 目录。 && mkdir ik unzip plugin this folder
./bin/elasticsearch-plugin install 不好用
#rebuild search index
curl '127.0.0.1/api/search/reindex'