add search_source as parameter to mlt to provide the actual search source as a query parameter and not in the body

This commit is contained in:
kimchy 2010-04-20 21:16:52 +03:00
parent 9bfbab8209
commit 3d6be1dc3f
1 changed files with 6 additions and 0 deletions

View File

@ -27,6 +27,7 @@ import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.Client;
import org.elasticsearch.rest.*;
import org.elasticsearch.search.Scroll;
import org.elasticsearch.util.Unicode;
import org.elasticsearch.util.json.JsonBuilder;
import org.elasticsearch.util.settings.Settings;
@ -73,6 +74,11 @@ public class RestMoreLikeThisAction extends BaseRestHandler {
}
if (request.hasContent()) {
mltRequest.searchSource(request.contentAsBytes());
} else {
String searchSource = request.param("search_source");
if (searchSource != null) {
mltRequest.searchSource(Unicode.fromStringAsBytes(searchSource));
}
}
} catch (Exception e) {
try {