下载网址 https://www.elastic.co/cn/elastic-stack/
elasticsearch.yml
修改 network.host 为 0.0.0.0
配置cluster.initial_master_nodes为当前node,默认为注释,放开注释就行了
cluster.initial_master_nodes: ["node-1", "node-2"]
windows下安装ik分词插件:
先进入elasticsearch的bin文件夹,然后运行以下命令:
elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.14.0/elasticsearch-analysis-ik-7.14.0.zip
ik的版本要和elasticsearch版本一致
安装elasticsearch-analysis-pinyin分词器:安装方法同上
创建mappings(就是创建表,及结构)
PUT /test
{
"mappings": {
"properties":{
"id":{
"type":"integer"
},
"title":{
"type":"text",
"analyzer": "ik_max_word"
},
"des":{
"type":"text",
"analyzer": "ik_max_word"
}
}
}
}
高亮查询
GET test/_search
{
"query" : { "term" : { "字段" : "查询关键字" }},
"highlight" : {
"pre_tags" : ["
"post_tags" : ["
"fields" : {
"字段" : {}
}
}
}
elasticsearch查询英文是不区分大小写的,要不就是前台返回全部转换成小写,要不就是在mapping的时候设置不区分大小写查询