elasticsearch regex escape of '.' for case insensitivity backend options

Signed-off-by: Nate Guagenti <neu5ron@users.noreply.github.com>
This commit is contained in:
Nate Guagenti
2020-08-25 13:10:25 -04:00
parent 474e04dfe3
commit a7ffb96b6b
+2
View File
@@ -217,6 +217,8 @@ class ElasticsearchWildcardHandlingMixin(object):
#value = re.sub( r"((?<!\\)(\\))\*$", "\g<1>\\*", value )
# Make upper/lower
value = re.sub( r"[A-Za-z]", lambda x: "[" + x.group( 0 ).upper() + x.group( 0 ).lower() + "]", value )
# Turn `.` into wildcard, only if odd number of '\'(because this would mean already escaped)
value = re.sub( r"(((?<!\\)(\\\\)+)|(?<!\\))\.", "\g<1>\.", value )
# Turn `*` into wildcard, only if odd number of '\'(because this would mean already escaped)
value = re.sub( r"(((?<!\\)(\\\\)+)|(?<!\\))\*", "\g<1>.*", value )
# Escape additional values that are treated as specific "operators" within Elastic. (ie: @, ?, &, <, >, and ~)