URI routing parameter does not work with Bulk API

closes #4053
This commit is contained in:
Shay Banon 2013-11-03 02:15:50 +01:00
parent b0a8abeb88
commit a8535e247e
3 changed files with 7 additions and 6 deletions

View File

@ -245,7 +245,7 @@ public class BulkProcessor {
}
public synchronized BulkProcessor add(BytesReference data, boolean contentUnsafe, @Nullable String defaultIndex, @Nullable String defaultType, @Nullable Object payload) throws Exception {
bulkRequest.add(data, contentUnsafe, defaultIndex, defaultType, payload, true);
bulkRequest.add(data, contentUnsafe, defaultIndex, defaultType, null, payload, true);
executeIfNeeded();
return this;
}

View File

@ -235,17 +235,17 @@ public class BulkRequest extends ActionRequest<BulkRequest> {
* Adds a framed data in binary format
*/
public BulkRequest add(BytesReference data, boolean contentUnsafe, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception {
return add(data, contentUnsafe, defaultIndex, defaultType, null, true);
return add(data, contentUnsafe, defaultIndex, defaultType, null, null, true);
}
/**
* Adds a framed data in binary format
*/
public BulkRequest add(BytesReference data, boolean contentUnsafe, @Nullable String defaultIndex, @Nullable String defaultType, boolean allowExplicitIndex) throws Exception {
return add(data, contentUnsafe, defaultIndex, defaultType, null, allowExplicitIndex);
return add(data, contentUnsafe, defaultIndex, defaultType, null, null, allowExplicitIndex);
}
public BulkRequest add(BytesReference data, boolean contentUnsafe, @Nullable String defaultIndex, @Nullable String defaultType, @Nullable Object payload, boolean allowExplicitIndex) throws Exception {
public BulkRequest add(BytesReference data, boolean contentUnsafe, @Nullable String defaultIndex, @Nullable String defaultType, @Nullable String defaultRouting, @Nullable Object payload, boolean allowExplicitIndex) throws Exception {
XContent xContent = XContentFactory.xContent(data);
int from = 0;
int length = data.length();
@ -276,7 +276,7 @@ public class BulkRequest extends ActionRequest<BulkRequest> {
String index = defaultIndex;
String type = defaultType;
String id = null;
String routing = null;
String routing = defaultRouting;
String parent = null;
String timestamp = null;
Long ttl = null;

View File

@ -75,6 +75,7 @@ public class RestBulkAction extends BaseRestHandler {
bulkRequest.listenerThreaded(false);
String defaultIndex = request.param("index");
String defaultType = request.param("type");
String defaultRouting = request.param("routing");
String replicationType = request.param("replication");
if (replicationType != null) {
@ -86,7 +87,7 @@ public class RestBulkAction extends BaseRestHandler {
}
bulkRequest.refresh(request.paramAsBoolean("refresh", bulkRequest.refresh()));
try {
bulkRequest.add(request.content(), request.contentUnsafe(), defaultIndex, defaultType, allowExplicitIndex);
bulkRequest.add(request.content(), request.contentUnsafe(), defaultIndex, defaultType, defaultRouting, null, allowExplicitIndex);
} catch (Exception e) {
try {
XContentBuilder builder = restContentBuilder(request);