elasticsearch - 如何在弹性搜索中决定正则表达式和通配符
问题描述
当我们尝试对大约 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"}}]}
解决方案
推荐阅读
- c++ - 如何使用 range-v3 库从 std::vector 获取列视图和行视图?
- c - 为什么可以在 C 中生成动态大小的数组?
- python - 如何使用Python将各个数字的索引存储在单独数组中的列表中
- java - Kafka Consumer架构设计:java插件或外部客户端
- dynamics-crm - CRM 操作中的可选输入参数在代码活动中始终为 NULL,即使未通过?
- powershell - 用户通过 powershell 脚本插入后 CN 中的“\”字符
- ssrs-2016 - 在 iif 子句条件中连接多个字段时,在 SSRS 报告生成器 2016 中显示错误
- ios - 如何在 UITextField 上显示验证错误?
- python - 如何在列表列表中找到列表的名称而不是其值?
- react-native - 由于旧的 react-native-vector-icons 版本,无法构建 react-native-elements