1

I have some queries regarding the Surround QueryParser. Could any of you please suggest?

  1. How to search multiple fields at once?

As shown below, the syntax allows to search against one field. But how do I submit a query like "FIELD1:N(abc,corp) FIELD2:N(xyz,corp)". Is something like this possible with Surround QueryParser?

SrndQuery srndQuery = org.apache.lucene.queryparser.surround.parser.QueryParser.parse(strTxtSearchString); Query query = srndQuery.makeLuceneQueryField(, new BasicQueryFactory());

  1. How to escape special characters the way we do in the regular QueryParser as queryparser.escape();

  2. How to escape words such as "and", "or", "W", "N" etc.? The search string itself might have the words such as "and". In that case, my query would look something like "N(abc,and,sons)" or "W(abc,n,company)".

I get a org.apache.lucene.queryparser.surround.parser.ParseException when I submit such a query.

  1. How to provide wild card in the beginning of the words?

The regular QueryParser lets us do parser.setAllowLeadingWildcard(true); Is there some way to do this with the Surround QueryParser?

Any inputs will be very helpful. Thanks!

  • It would probably be helpful to break this question into related pieces. You talk about at least: surround queries with multiple fields; escaping words; wildcards. – Pablo Mendes May 13 '14 at 23:01

0 Answers0