Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org.apache.lucene.queryParser.ParseException

I got the below error in my project:

org.apache.lucene.queryParser.ParseException: Cannot parse 'AMERICAN EXP PROPTY CASLTY INS AND': Encountered "" at line 1, column 34. Was expecting one of: ... "+" ... "-" ... "(" ... "" ... ... ... ... ... "[" ... "{" ... ... ... "" ...

at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:211)
at org.elasticsearch.index.query.xcontent.QueryStringQueryParser.parse(QueryStringQueryParser.java:196)
... 15 more

Please help on how to resolve...when i add an AND at the end of any string it gives me the above error.

Thanks

like image 985
Rajni Avatar asked Mar 07 '26 21:03

Rajni


1 Answers

When you are using QueryString query or specifying your query as a q parameter, elasticsearch is using Lucene to parse your query. As a result, it expects your query to follow Lucene query syntax and returns errors when your query contains syntax errors (dangling AND at the end, in your case). If you want your query string to be interpreted as text and not parsed as a query, consider using Text Query instead.

like image 200
imotov Avatar answered Mar 09 '26 13:03

imotov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!