use of io.zulia.message.ZuliaQuery in project zuliasearch by zuliaio.
the class ZuliaIndex method parseQueryToLucene.
private Query parseQueryToLucene(ZuliaQuery.Query zuliaQuery) throws Exception {
try {
ZuliaQuery.Query.Operator defaultOperator = zuliaQuery.getDefaultOp();
String queryText = zuliaQuery.getQ();
int minimumShouldMatchNumber = zuliaQuery.getMm();
List<String> queryFields = zuliaQuery.getQfList();
if (queryText.isEmpty()) {
if (queryFields.isEmpty()) {
return new MatchAllDocsQuery();
} else {
queryText = "*";
}
}
Collection<String> defaultSearchFieldList;
if (queryFields.isEmpty()) {
defaultSearchFieldList = indexConfig.getIndexSettings().getDefaultSearchFieldList();
} else {
defaultSearchFieldList = queryFields;
}
Query query;
boolean dismax = zuliaQuery.getDismax();
float dismaxTie = zuliaQuery.getDismaxTie();
if (zuliaQuery.getLegacy()) {
query = parseWithLegacyQueryParser(queryText, minimumShouldMatchNumber, defaultOperator, defaultSearchFieldList, dismax, dismaxTie);
} else {
query = parseWithQueryParser(queryText, minimumShouldMatchNumber, defaultOperator, defaultSearchFieldList, dismax, dismaxTie);
}
boolean negative = QueryUtil.isNegative(query);
if (negative) {
query = QueryUtil.fixNegativeQuery(query);
}
return query;
} catch (ParseException e) {
throw new IllegalArgumentException("Invalid Query: " + zuliaQuery.getQ());
}
}
Aggregations