首页 > 解决方案 > 如何在弹性搜索中决定正则表达式和通配符

问题描述

当我们尝试对大约 10 个不同的术语进行正则表达式时,我们得到以下异常:

ElasticsearchException[Elasticsearch exception [type=too_complex_to_determinize_exception, reason=too_complex_to_determinize_exception: Determinizing automaton with 67 states and 278 transitions would result in more than 10000 states.]];

增加提升将解决错误。但是通过的术语数量会有所不同,并且无法固定特定值。我正在考虑使用通配符。

通配符也在内部创建状态,那么使用通配符是更好的方法还是有更好的方法?

我使用正则表达式的示例查询:

search {"from":0,"size":0,"timeout":"60s","query":{"bool":{"must":[{"regexp":{"filed_name":

{"value":".*term.*|.*term.*|.*term.*|.*term.*|.*term.*|.*term.*|.*term.*|.*term.*|.*term.*|.*term.*|.*term.*","flags_value":65535,"max_determinized_states":10000,"boost":1.0}

}},{"range":{"condition_field":

{"from":0,"to":null,"include_lower":false,"include_upper":true,"boost":1.0}

}},{"range":{"condition_filed":

{"from":0,"to":null,"include_lower":false,"include_upper":true,"boost":1.0}

}}],"adjust_pure_negative":true,"boost":1.0}},"profile":true,"sort":[{"_id":{"order":"asc"}}]}

标签: elasticsearch

解决方案


推荐阅读