Docs/ELK/es基础.md
2022-10-18 16:59:37 +08:00

135 lines
No EOL
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#### 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"
}
}
}
}
```