Skip to content

Parse error when contains "(" #2631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pengzhiwei2018 opened this issue Apr 27, 2025 · 6 comments
Open

Parse error when contains "(" #2631

pengzhiwei2018 opened this issue Apr 27, 2025 · 6 comments

Comments

@pengzhiwei2018
Copy link

pengzhiwei2018 commented Apr 27, 2025

Describe the bug
when the term query contains "(" or ")" the query parser will fail, like:
content :y+(y+25)

How to support this case with "(" in the match string.

@pengzhiwei2018
Copy link
Author

pengzhiwei2018 commented Apr 28, 2025

@trinity-1686a can you help for this issue? It doesn't work even though I have done the escaping processing for ‘(’

@trinity-1686a
Copy link
Contributor

is the space after content on purpose? If so it should be escaped content\ :y+\(y+25\), but i would expect it's likely unwanted, in which case it should just be removed content:y+\(y+25\) (or you can use the single quote syntax to not have to handle as many escape sequences: content:'y+(y+25)')

beware depending on the tokenizer you use, queries with non-word chars might not yield the results you expect

@pengzhiwei2018
Copy link
Author

@trinity-1686a thanks to you help. I test content:'y+(y+25)' works, but content:y+\(y+25\) still throw parse exception.

@trinity-1686a
Copy link
Contributor

what version of tantivy are you running? By bissecting, it seems this if fixed in 455156f , which is present in the v0.24 series

@pengzhiwei2018
Copy link
Author

I work in v0.22, I will have a try for v0.24.

@pengzhiwei2018
Copy link
Author

Hi @trinity-1686a , I found another performance issue about the special char. The query content:'()' or content:'{}' takes 100ms in my test case while query content:'abc' which only take 50us. There are about 2000x performace gap on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants