如何在弹性搜索中使用正则表达式? [英] how to using regexp in elasticsearch?
问题描述
我在elcsearch有很多字段名称,例如
:
i have a lot of field name in elcsearch , for example :
web_logfield_A,web_logfield_B,web_logfield_C :: abc ,
apach_logfield_A,apach_logfield_A
web_logfield_A, web_logfield_B ,web_logfield_C::abc,
apach_logfield_A, apach_logfield_A
如果我想获取这些字段的值(
web_logfield_A,web_logfield_B ,web_logfield_C :: abc)
if i want to get these fields value ( web_logfield_A, web_logfield_B ,web_logfield_C::abc )
我可以使用Regex表达式查询field name来查询
can i using Regex expression for "field name" to query like
/web_logfield[A-Za-a_]+/
尝试使用.setQuery(QueryBuilders.termQuery(,),
但它看起来不能这样做?
JAVA API中的哪个方法可以做到这一点?
i have try to using .setQuery(QueryBuilders.termQuery("",""), but it's looks like cannot do that ? which method in JAVA API can do that ?
推荐答案
您应该尝试使用 query_string
查询这样
You should try with a query_string
query like this
.setQuery(QueryBuilders.queryStringQuery("xyz").field("web_logfield_*"))
其中 xyz
是您要在这些字段中匹配的内容
where xyz
is what you're trying to match in those fields
这篇关于如何在弹性搜索中使用正则表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!