100 lines
721 B
Markdown
100 lines
721 B
Markdown
- 有书签
|
||
|
||
- Marvel - 监控管理工具
|
||
|
||
|
||
|
||
## 与关系型数据库对比
|
||
Relational DB -> Databases -> Tables -> Rows -> Columns
|
||
|
||
Elasticsearch -> Indices -> Types -> Documents -> Fields
|
||
|
||
|
||
|
||
|
||
|
||
## 查询语法
|
||
|
||
### 集群中的文档数量
|
||
```
|
||
|
||
curl -XGET 'http://localhost:9200/_count?pretty' -d '
|
||
|
||
{
|
||
|
||
"query": {
|
||
|
||
"match_all": {}
|
||
|
||
}
|
||
|
||
}
|
||
```
|
||
|
||
|
||
|
||
### 查询
|
||
```
|
||
|
||
GET /megacorp/employee/_search
|
||
{
|
||
|
||
"query" : {
|
||
|
||
"filtered" : {
|
||
|
||
"filter" : {
|
||
|
||
"range" : {
|
||
|
||
"age" : { "gt" : 30 } <1>
|
||
|
||
}
|
||
|
||
},
|
||
|
||
"query" : {
|
||
|
||
"match" : {
|
||
|
||
"last_name" : "smith" <2>
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
```
|
||
|
||
|
||
|
||
### 短语搜索
|
||
|
||
|
||
```
|
||
|
||
GET /megacorp/employee/_search
|
||
|
||
{
|
||
|
||
"query" : {
|
||
|
||
"match_phrase" : {
|
||
|
||
"about" : "rock climbing"
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
```
|