Elasticsearch常用简单DSL

2020-05-22 00:00:00 查询 数据 匹配 就能 中秋

1. 简单查询

# 查询所有
GET /tmpl-word-log*/_search
{
  "query": {
    "match_all": {}
  }
}

# 查询固定条数(默认size=10)
GET /tmpl-word-log*/_search
{
  "size": 2,
  "query": {
    "match_all": {}
  }
}

# 查询从10-15条数据(from默认从0开始)
GET /tmpl-word-log*/_search
{
  "query": {
    "match_all": {}
  }
  "form": 9,
  "size": 5
}

# 按某字段(时间)排序,desc降序,asc升序
GET /tmpl-word-log*/_search
{
  "query": {
    "match_all": {}
  }
  , "sort": [
    {
      "@timestamp": {
        "order": "desc"
      }
    }
  ]
}

# 只查询某些字段
GET /tmpl-word-log*/_search
{
  "size": 2,
  "query": {
    "match_all": {}
  }
  , "_source": ["@timestamp", "index"]
}

相关文章