Reputation: 1449
I read up ElasticSearch's regex query documentation : https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html
Nowhere is it mentioned what happens if a malformed regex is passed on into the query.
So my question is , what happens if the regex is malformed ? Is an exception thrown , or an error message of some kind ?
Thanks!
Upvotes: 0
Views: 744
Reputation: 819
Elasticsearch throws an exception. I added an extra [
and ran the regex query using the Dev Tools Console in Kibana.
GET indexname/_search
{
"query": {
"regexp":{
"field_name": "t.[st"
}
}
}
And I get search_phase_exception
as follows:
{
"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
}
Hope that helps!
Upvotes: 2