URI routing parameter support with multi search API

Support URI level routing parameter for the multi search API, that will act as the default routing (unless explicitly set).
closes #4058
This commit is contained in:
Shay Banon 2013-11-03 02:30:19 +01:00
parent a8535e247e
commit 8f88d0aa4a
2 changed files with 7 additions and 4 deletions

View File

@ -70,14 +70,14 @@ public class MultiSearchRequest extends ActionRequest<MultiSearchRequest> {
public MultiSearchRequest add(byte[] data, int from, int length, boolean contentUnsafe,
@Nullable String[] indices, @Nullable String[] types, @Nullable String searchType) throws Exception {
return add(new BytesArray(data, from, length), contentUnsafe, indices, types, searchType, IgnoreIndices.NONE, true);
return add(new BytesArray(data, from, length), contentUnsafe, indices, types, searchType, null, IgnoreIndices.NONE, true);
}
public MultiSearchRequest add(BytesReference data, boolean contentUnsafe, @Nullable String[] indices, @Nullable String[] types, @Nullable String searchType, IgnoreIndices ignoreIndices) throws Exception {
return add(data, contentUnsafe, indices, types, searchType, ignoreIndices, true);
return add(data, contentUnsafe, indices, types, searchType, null, ignoreIndices, true);
}
public MultiSearchRequest add(BytesReference data, boolean contentUnsafe, @Nullable String[] indices, @Nullable String[] types, @Nullable String searchType, IgnoreIndices ignoreIndices, boolean allowExplicitIndex) throws Exception {
public MultiSearchRequest add(BytesReference data, boolean contentUnsafe, @Nullable String[] indices, @Nullable String[] types, @Nullable String searchType, @Nullable String routing, IgnoreIndices ignoreIndices, boolean allowExplicitIndex) throws Exception {
XContent xContent = XContentFactory.xContent(data);
int from = 0;
int length = data.length();
@ -103,6 +103,9 @@ public class MultiSearchRequest extends ActionRequest<MultiSearchRequest> {
if (types != null && types.length > 0) {
searchRequest.types(types);
}
if (routing != null) {
searchRequest.routing(routing);
}
searchRequest.searchType(searchType);
// now parse the action

View File

@ -71,7 +71,7 @@ public class RestMultiSearchAction extends BaseRestHandler {
}
try {
multiSearchRequest.add(request.content(), request.contentUnsafe(), indices, types, request.param("search_type"), ignoreIndices, allowExplicitIndex);
multiSearchRequest.add(request.content(), request.contentUnsafe(), indices, types, request.param("search_type"), request.param("routing"), ignoreIndices, allowExplicitIndex);
} catch (Exception e) {
try {
XContentBuilder builder = restContentBuilder(request);