update lucene escaping (#233)

* update lucene escaping

* update unit test
This commit is contained in:
Preston Rasmussen 2024-12-09 10:36:46 -05:00 committed by GitHub
parent 8858be8cef
commit 732b2f328d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -57,6 +57,12 @@ def lucene_sanitize(query: str) -> str:
':': r'\:', ':': r'\:',
'\\': r'\\', '\\': r'\\',
'/': r'\/', '/': r'\/',
'O': r'\O',
'R': r'\R',
'N': r'\N',
'T': r'\T',
'A': r'\A',
'D': r'\D',
} }
) )

View File

@ -23,10 +23,10 @@ def test_lucene_sanitize():
# Call the function with test data # Call the function with test data
queries = [ queries = [
( (
'This has every secape character + - && || ! ( ) { } [ ] ^ " ~ * ? : \\ /', 'This has every escape character + - && || ! ( ) { } [ ] ^ " ~ * ? : \\ /',
'This has every secape character \+ \- \&\& \|\| \! \( \) \{ \} \[ \] \^ \\" \~ \* \? \: \\\ \/', '\This has every escape character \+ \- \&\& \|\| \! \( \) \{ \} \[ \] \^ \\" \~ \* \? \: \\\ \/',
), ),
('This has no escape characters', 'This has no escape characters'), ('this has no escape characters', 'this has no escape characters'),
] ]
for query, assert_result in queries: for query, assert_result in queries: