美文网首页
Elasticsearch Reference 5.2.2

Elasticsearch Reference 5.2.2

作者: 青丝如梦 | 来源:发表于2019-11-07 13:36 被阅读0次

官方文档: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"
      }
    }
  ]
}

新增

删除

{"query":{"match_all":{}}}

相关文章

网友评论

      本文标题:Elasticsearch Reference 5.2.2

      本文链接:https://www.haomeiwen.com/subject/engubctx.html