2.5 KiB
2.5 KiB
es配置建议
1、jvm中的xmx不要超过机器内存的一半 2、不要超过30G
查看es安装的插件
bin/elasticsearch-plugin list
安装插件
## 安装分析器(analysis-icu国际化分析插件)
bin/elasticsearch-plugin install analysis-icu
查看集群运行了哪些节点
# 浏览器访问
http://localhost:9200/_cat/nodes
_all字段表示所有数据,7.0+已废除
Phrase查询,需要使用引号
GET /movies/_search?q=title:"Beautiful Mind"
{
"profile":"true"
}
AND OR NOT等
# AND,OR,NOR必须大写
## title中包含 Beautiful和Mind
GET /movies/_search?q=title:(Beautiful AND Mind)
{
"profile":"true"
}
## title中包含 Beautiful不包含Mind
GET /movies/_search?q=title:(Beautiful NOT Mind)
{
"profile":"true"
}
## title中包含 Beautiful必须包含Mind(%2B为=)
GET /movies/_search?q=title:(Beautiful %2BMind)
{
"profile":"true"
}
近似查询
## beautiful输入错误
GET /movies/_search?q=title:beautilfl~1
{
"profile":"true"
}
模糊查询
## 搜索Lord of The Rings
GET /movies/_search?q=title:"Lord Rings"~2
{
"profile":"true"
}
设置mappings
PUT movies
{
"mappings": {
"_doc": {
"dynamic": "false" ## 新文档的新增字段无法索引,文档可以索引,mappings不更新
}
}
}
PUT movies
{
"mappings": {
"_doc": {
"dynamic": "true" ## 新文档的新增字段可以索引,文档可以索引,mappings更新
}
}
}
PUT movies
{
"mappings": {
"_doc": {
"dynamic": "stict" ## 新文档的新增字段不可以索引,文档不可以索引,mappings不更新,数据写入直接拒绝,报错
}
}
}
PUT users
{
"mappings": {
"mobile": {
"type": "text"
"index": "false" ## 该字段不索引,true表示需要索引
}
}
}
PUT users
{
"mappings": {
"mobile": {
"type": "keyword"
"null_value": "NULL" ## 可以直接查询"mobile": "NULL"
}
}
}
## 把firstName和lastName复制到fullName中,即使新文档没有fullName字段,也可以查询fullName,结果展示中不存在fullName
PUT users
{
"mappings": {
"properties": {
"firstName": {
"type": "text"
"copy_to": "fullName"
},
"lastName": {
"type": "text"
"copy_to": "fullName"
}
}
}
}