Reputation: 117
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
Upvotes: 3
Views: 4168
Reputation: 327
use correct package name and classpath parser P is small letter
org.apache.lucene.queryparser.classic.ParseException
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>4.3.0</version>
</dependency>
Upvotes: 0
Reputation: 30153
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.
Upvotes: 3
Reputation: 14492
That's funny. Lucene is waiting for a new term as in Lucene you can build queries like : "termA AND termB" or "+termA +termB"
Can you try to lowercase your query and see if it works?
Upvotes: 0