官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/5.2/index.html
cat APIs
cat nodes
- nodes命令显示集群拓扑结构:
http://192.168.0.1:9200/_cat/nodes?v
Query DSL
Full text queries
Simple Query String Query
- 查询带有hyphen(中横线'-')的字段:
http://192.168.0.1:9200/index_name/index_type/
_search
POST
{
"_source": true,
"query": {
"simple_query_string": {
"query": "user-department*",
"analyze_wildcard": true,
"default_operator": "AND"
}
}
}
analyze_wildcard: 分析通配符,默认false
查询
-
复杂查询 POST:
image.png -
非空判断查询
create_time字段必须存在,且create_time字段的值不能为null
image.png
{
"query": {
"constant_score": {
"filter": {
"exists": {
"field": "create_time"
}
}
}
}
}
- 复杂查询
exists:
log、create_time 字段必须存在且不为null,但可以是""(空字符串)
_source:
指定文档返回哪些字段
{
"size": 10000,
"_source": [
"create_time"
],
"query": {
"bool": {
"must": [
{
"exists": {
"field": "log"
}
},
{
"exists": {
"field": "create_time"
}
},
{
"range": {
"create_time": {
"from": 1572836551000,
"to": 1572836551000,
"include_lower": true,
"include_upper": true,
"boost": 1
}
}
},
{
"terms": {
"id": [
"1572836615897#ub4hTLen#1"
],
"boost": 1
}
}
],
"disable_coord": false,
"adjust_pure_negative": true,
"boost": 1
}
},
"sort": [
{
"create_time": {
"order": "desc"
}
}
]
}
新增
-
根据路由新增操作:
?routing=base
image.png - image.png
删除
-
根据ID删除一条:
DELETE请求 http://192.168.200.8:9200/indexName/type/_id(ES的主键ID) -
删除所有数据:
POST请求 http://192.168.200.8:9200/indexName/_delete_by_query/
{"query":{"match_all":{}}}
网友评论