当前位置:   article > 正文

ES实战--wildcard正则匹配&exists过滤字段是否存在_es wildcard

es wildcard

wildcard 通配符中的 * 表示任意数量的字符
?表示任意单个字符

#正则匹配
GET /wildcard-test/_search
{
  "query": {
    "wildcard": {
      "title": {
        "wildcard": "ba*n"
      }
    }
  }
}
#响应:
  "hits": {
    "total": {
      "value": 2,
      "relation": "eq"
    },
    "max_score": 1,
    "hits": [
      {
        "_index": "wildcard-test",
        "_id": "1",
        "_score": 1,
        "_source": {
          "title": "The Best Bacon Ever"
        }
      },
      {
        "_index": "wildcard-test",
        "_id": "2",
        "_score": 1,
        "_source": {
          "title": "How to raise a barn"
        }
      }
    ]
  }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37

exists过滤器

#过滤出某个字段有值的文档
GET /get-together/_search
{
  "query": {
    "bool": {
      "filter": {
        "exists": {"field": "location_event.geolocation"}
      }
    }
  }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小桥流水78/article/detail/882664
推荐阅读
相关标签
  

闽ICP备14008679号