use of co.elastic.clients.elasticsearch._types.query_dsl.QueryVariant in project para-search-elasticsearch by Erudika.
the class ESUtils method convertQueryStringToNestedQuery.
/**
* Convert a normal query string query to one which supports nested fields.
* Reference: https://github.com/elastic/elasticsearch/issues/11322
* @param query query string
* @return a list of composite queries for matching nested objects
*/
static QueryVariant convertQueryStringToNestedQuery(String query) {
// nested array syntax
String queryStr = StringUtils.trimToEmpty(query).replaceAll("\\[(\\d+)\\]", "-$1");
Query q = qsParsed(queryStr);
if (q == null) {
return QueryBuilders.matchAll().build();
}
try {
return rewriteQuery(q, 0);
} catch (Exception e) {
logger.warn(e.getMessage());
return null;
}
}
Aggregations