rest _count endpoint to also allow for no query provided (defaults to match_all)
This commit is contained in:
parent
a76737ceaf
commit
6b497589ce
|
@ -76,7 +76,10 @@ public class RestCountAction extends BaseRestHandler {
|
|||
if (source != null) {
|
||||
countRequest.query(source);
|
||||
} else {
|
||||
countRequest.query(RestActions.parseQuerySource(request));
|
||||
byte[] querySource = RestActions.parseQuerySource(request);
|
||||
if (querySource != null) {
|
||||
countRequest.query(querySource);
|
||||
}
|
||||
}
|
||||
}
|
||||
countRequest.queryHint(request.param("query_hint"));
|
||||
|
|
|
@ -72,7 +72,7 @@ public class RestActions {
|
|||
public static byte[] parseQuerySource(RestRequest request) {
|
||||
String queryString = request.param("q");
|
||||
if (queryString == null) {
|
||||
throw new ElasticSearchIllegalArgumentException("No query to execute, not in body, and not bounded to 'q' parameter");
|
||||
return null;
|
||||
}
|
||||
QueryStringQueryBuilder queryBuilder = QueryBuilders.queryString(queryString);
|
||||
queryBuilder.defaultField(request.param("df"));
|
||||
|
|
Loading…
Reference in New Issue