大模型-win本地安装 elastic search-48
elasticsearch
docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.10.1
-d:以守护进程模式运行容器。
--name elasticsearch:为容器指定名称。
-p 9200:9200 -p 9300:9300:将容器的9200和9300端口映射到主机上,以便外部访问。
-e "discovery.type=single-node":设置环境变量告诉Elasticsearch这是一个单节点集群。
最后是使用的镜像名和版本号。
kibana
docker run -d --name kibana -p 5601:5601 --link elasticsearch:elasticsearch docker.elastic.co/kibana/kibana:7.10.1
添加
curl -X POST "localhost:9200/my-index/_doc/" -H 'Content-Type: application/json' -d'
{
"title": "Elasticsearch入门",
"content": "Elasticsearch是一个基于Lucene的搜索引擎"
}'
查询
curl -X GET "localhost:9200/my-index/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"match": {
"content": "搜索引擎"
}
}
}'
使用开发工具
http://localhost:5601/app/dev_tools#/console
GET my-index/_search
{
"query": {
"match": {
"content": "搜索"
}
}
}
# 查询所有
GET my-index/_search
{
"query": {
"match_all": {}
}
}
安装analysis-ik
进入容器内
./bin/elasticsearch-plugin install https://release.infinilabs.com/analysis-ik/stable/elasticsearch-analysis-ik-7.10.1.zip
./bin/elasticsearch-plugin instal
推出重启容器
docker restart elasticsearch
IK分词器包含两种模式:
-
ik_smart:最少切分 -
ik_max_word:最细切分
再用dev_tools发起请求
GET /_analyze
{
"analyzer": "ik_max_word",
"text": "是一个基于Lucene的搜索引"
}
{
"tokens" : [
{
"token" : "是",
"start_offset" : 0,
"end_offset" : 1,
"type" : "CN_CHAR",
"position" : 0
},
{
"token" : "一个",
"start_offset" : 1,
"end_offset" : 3,
"type" : "CN_WORD",
"position" : 1
},
{
"token" : "一",
"start_offset" : 1,
"end_offset" : 2,
"type" : "TYPE_CNUM",
"position" : 2
},
{
"token" : "个",
"start_offset" : 2,
"end_offset" : 3,
"type" : "COUNT",
"position" : 3
}
...
}
扩展新词
[root@a9fc2030e08e elasticsearch]# find . -name "IKAnal*"
./config/IKAnalyzer.cfg.xml
./config/analysis-ik/IKAnalyzer.cfg.xml
修改配置增加ext.dic
cd ./config/analysis-ik/
vi ext.dic
chown elasticsearch: ext.dic
docker restart elasticsearch
# 注意文件的位置
/usr/share/elasticsearch/config/analysis-ik/ext.dic
白嫖
奥力给
注意格式xml
查看日志:
同样的方式配置停用的字典
echo "刷币" >> /usr/share/elasticsearch/config/analysis-ik/ext.dic/stopword.dic
GET /_analyze
{
"analyzer": "ik_max_word",
"text": "刷币,我是真的会谢,都点赞白嫖,!"
}
安装jieba分词
./bin/elasticsearch-plugin install https://github.com/sing1ee/elasticsearch-jieba-plugin/archive/refs/tags/v7.7.1.zip

浙公网安备 33010602011771号