ElasticSearch 查询

Create an index
PUT /books
获取index详情

GET /books
id查询

GET /books/_doc/1

查看索引列表

GET /_cat/indices?v

添加文档
POST books/_doc/1
{
  "name": "Snow Crash",
  "author": "Neal Stephenson",
  "release_date": "1992-06-01",
  "page_count": 470
}
更新文档

POST books/_update/1
{
  "doc": {
    "title": "zhaohongfeng title"
  }
}
查看mapping

GET /books/_mapping

Perform a search in my-index

GET /books/_search

删除数据

delete /books/_doc/1

条件查询

GET /books/_search?q=page_count:470

条件查询


GET /books/_search
{
  "query": {
    "match": {
      "page_count": 470
    }
  }
}
分页查询

GET /books/_search
{
  "query": {
    "term": {
      "page_count": 470
    }
  },
  "from": 0,
  "size": 20,
  "_source": [
    "page_count",
    "name"
  ],
  "sort": [
    {
      "page_count": {
        "order": "desc"
      }
    }
  ]
}
多条件查询

GET /books/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "page_count": 470
          }
        },
        {
          "match": {
            "release_date": "1992-06-01"
          }
        }
      ],
      "filter": {
        "range": {
          "page_count": {
            "gte": 10,
            "lte": 20
          }
        }
      }
    }
  }
}

results matching ""

    No results matching ""