osma commented on issue #536: Add support SurroundQueryParser to jena-text URL: https://github.com/apache/jena/pull/536#issuecomment-478569188 I still don't get the `switch` block. The control flow seems just...messy, with all the `if` checks and sometimes implicitly falling through to the next case, sometimes not. How about this: ```java switch(queryParserType) { case "SurroundQueryParser": try { query = org.apache.lucene.queryparser.surround.parser.QueryParser.parse(queryString).makeLuceneQueryField(docDef.getPrimaryField(), new BasicQueryFactory()); } catch(org.apache.lucene.queryparser.surround.parser.ParseException e) { throw new ParseException(e.getMessage()); } return query; case "ComplexPhraseQueryParser": qp = new ComplexPhraseQueryParser(docDef.getPrimaryField(), analyzer); break; default: log.warn("Unknown query parser type '" + queryParserType + "'. Defaulting to standard QueryParser"); case "AnalyzingQueryParser": // since Lucene 7 analyzing is done by QueryParser case "QueryParser": qp = new QueryParser(docDef.getPrimaryField(), analyzer); } } qp.setAllowLeadingWildcard(true); query = qp.parse(queryString); return query ; ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
