xristy commented on issue #536: Add support SurroundQueryParser to jena-text
URL: https://github.com/apache/jena/pull/536#issuecomment-478621634
 
 
   I also had second thoughts about the needless instantiation and almost 
edited the previous as follows:
   
   ```java
       private Query parseQuery(String queryString, Analyzer analyzer) throws 
ParseException {
           Query query = null;
           QueryParser qp = null;
   
           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;
               case "AnalyzingQueryParser": // since Lucene 7 analyzing is done 
by QueryParser
                   log.warn("Deprecated query parser type 
'AnalyzingQueryParser'. Defaulting to standard QueryParser");
                   break;
               default:
                   log.warn("Unknown query parser type '" + queryParserType + 
"'. Defaulting to standard QueryParser");
           }
   
           if (qp == null) 
               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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to