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

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"
        }
      }
    ]
  }

exists过滤器

#过滤出某个字段有值的文档
GET /get-together/_search
{
  "query": {
    "bool": {
      "filter": {
        "exists": {"field": "location_event.geolocation"}
      }
    }
  }
}

你可能感兴趣的:(elasticsearch)