Skip to content

Commit c6d1321

Browse files
committed
Search API: Allow to pass the body JSON also as a parameter named 'source', closes #140.
1 parent 3e430c2 commit c6d1321

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.elasticsearch.rest.action.support.RestActions;
3333
import org.elasticsearch.search.Scroll;
3434
import org.elasticsearch.search.builder.SearchSourceBuilder;
35+
import org.elasticsearch.util.Unicode;
3536
import org.elasticsearch.util.json.JsonBuilder;
3637
import org.elasticsearch.util.settings.Settings;
3738

@@ -116,6 +117,11 @@ private SearchRequest parseSearchRequest(RestRequest request) {
116117
// get the content, and put it in the body
117118
if (request.hasContent()) {
118119
searchRequest.source(request.contentAsBytes());
120+
} else {
121+
String source = request.param("source");
122+
if (source != null) {
123+
searchRequest.source(Unicode.fromStringAsBytes(source));
124+
}
119125
}
120126
// add extra source based on the request parameters
121127
searchRequest.extraSource(parseSearchSource(request));

0 commit comments

Comments
 (0)