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:
parent
a8535e247e
commit
8f88d0aa4a
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue