xristy commented on issue #536: Add support SurroundQueryParser to jena-text
URL: https://github.com/apache/jena/pull/536#issuecomment-478607770
 
 
   @osma cleaner, and I thought it was a good idea to alert users that they are 
using a deprecated query parser if they refer to `AnalyzingQueryParser`. How 
about:
   
   ```java
       private Query parseQuery(String queryString, Analyzer analyzer) throws 
ParseException {
           Query query = null;
           QueryParser qp = new QueryParser(docDef.getPrimaryField(), analyzer);
   
           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 '" + queryParserType 
+ "'. Defaulting to standard QueryParser");
                   break;
               default:
                   log.warn("Unknown query parser type '" + queryParserType + 
"'. Defaulting to standard QueryParser");
           }
   
           qp.setAllowLeadingWildcard(true);
           query = qp.parse(queryString);
           return query ;
       }
   ```
   
   I expect that most uses end up with the standard `QueryParser`.

----------------------------------------------------------------
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