use of org.apache.lucene.queryparser.classic.MultiFieldQueryParser in project textdb by TextDB.
the class RegexMatcherSourceOperator method createLuceneQuery.
public static Query createLuceneQuery(RegexSourcePredicate predicate) throws StorageException {
Query luceneQuery;
String queryString;
// Try to apply translator. If it fails, use scan query.
try {
queryString = RegexToGramQueryTranslator.translate(predicate.getRegex()).getLuceneQueryString();
} catch (com.google.re2j.PatternSyntaxException e) {
queryString = DataConstants.SCAN_QUERY;
}
// Try to parse the query string. It if fails, raise an exception.
try {
luceneQuery = new MultiFieldQueryParser(predicate.getAttributeNames().stream().toArray(String[]::new), RelationManager.getRelationManager().getTableAnalyzer(predicate.getTableName())).parse(queryString);
} catch (ParseException e) {
throw new StorageException(e);
}
return luceneQuery;
}
Aggregations