use of com.orientechnologies.lucene.parser.OLuceneMultiFieldQueryParser in project orientdb by orientechnologies.
the class OLuceneQueryBuilder method getQueryParser.
protected Query getQueryParser(OIndexDefinition index, String key, Analyzer analyzer) throws ParseException {
String[] fields;
if (index.isAutomatic()) {
fields = index.getFields().toArray(new String[index.getFields().size()]);
} else {
int length = index.getTypes().length;
fields = new String[length];
for (int i = 0; i < length; i++) {
fields[i] = "k" + i;
}
}
Map<String, OType> types = new HashMap<String, OType>();
for (int i = 0; i < fields.length; i++) {
String field = fields[i];
types.put(field, index.getTypes()[i]);
}
// for (Map.Entry<String, OType> typeEntry : types.entrySet()) {
// System.out.println("typeEntry = " + typeEntry);
// }
final OLuceneMultiFieldQueryParser queryParser = new OLuceneMultiFieldQueryParser(types, fields, analyzer);
queryParser.setAllowLeadingWildcard(allowLeadingWildcard);
queryParser.setLowercaseExpandedTerms(lowercaseExpandedTerms);
try {
return queryParser.parse(key);
} catch (org.apache.lucene.queryparser.classic.ParseException e) {
throw new ParseException(e.getMessage());
}
}
Aggregations