gpt4 book ai didi

regex - ElasticSearch错误的正则表达式

转载 作者:行者123 更新时间:2023-12-03 00:55:42 29 4
gpt4 key购买 nike

我阅读了ElasticSearch的正则表达式查询文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html

它没有提到如果格式不正确的正则表达式传递到查询中会发生什么情况。

所以我的问题是,如果正则表达式格式不正确怎么办?是引发异常还是某种错误消息?

谢谢!

最佳答案

Elasticsearch引发异常。我添加了一个额外的[,并使用Kibana中的Dev Tools Console运行了正则表达式查询。

GET indexname/_search
{
"query": {
"regexp":{
"field_name": "t.[st"
}
}
}

我得到 search_phase_exception如下:
{
"error": {
"root_cause": [
{
"type": "query_shard_exception",
"reason": "failed to create query: {\n \"regexp\" : {\n \"field_name\" : {\n \"value\" : \"t.[st\",\n \"flags_value\" : 65535,\n \"max_determinized_states\" : 10000,\n \"boost\" : 1.0\n }\n }\n}",
"index_uuid": "6fy0LZRxQrOrNEFMGqL0wA",
"index": "indexname"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "systems",
"node": "LvCoGAkyTbiVIeyF7UtXTw",
"reason": {
"type": "query_shard_exception",
"reason": "failed to create query: {\n \"regexp\" : {\n \"field_name\" : {\n \"value\" : \"t.[st\",\n \"flags_value\" : 65535,\n \"max_determinized_states\" : 10000,\n \"boost\" : 1.0\n }\n }\n}",
"index_uuid": "6fy0LZRxQrOrNEFMGqL0wA",
"index": "indexname",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "expected ']' at position 5"
}
}
}
]
},
"status": 400
}

希望有帮助!

关于regex - ElasticSearch错误的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44663033/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com