Count / Delete By Query API: Add source parameter to pass the json body, closes #142.

This commit is contained in:
kimchy 2010-04-17 23:06:27 +03:00
parent 19b355e9f0
commit fbc138e38c
1 changed files with 5 additions and 0 deletions

View File

@ -26,6 +26,7 @@ import org.elasticsearch.index.query.json.JsonQueryBuilders;
import org.elasticsearch.index.query.json.QueryStringJsonQueryBuilder; import org.elasticsearch.index.query.json.QueryStringJsonQueryBuilder;
import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.util.Strings; import org.elasticsearch.util.Strings;
import org.elasticsearch.util.Unicode;
import org.elasticsearch.util.json.JsonBuilder; import org.elasticsearch.util.json.JsonBuilder;
import java.io.IOException; import java.io.IOException;
@ -67,6 +68,10 @@ public class RestActions {
if (request.hasContent()) { if (request.hasContent()) {
return request.contentAsBytes(); return request.contentAsBytes();
} }
String source = request.param("source");
if (source != null) {
return Unicode.fromStringAsBytes(source);
}
String queryString = request.param("q"); String queryString = request.param("q");
if (queryString == null) { if (queryString == null) {
throw new ElasticSearchIllegalArgumentException("No query to execute, not in body, and not bounded to 'q' parameter"); throw new ElasticSearchIllegalArgumentException("No query to execute, not in body, and not bounded to 'q' parameter");