ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

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

2026/8/14 23:01:38 拓冰建站 浏览量
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"}}}}
}