Skip to content

Commit

Permalink
URI routing parameter does not work with Bulk API
Browse files Browse the repository at this point in the history
  • Loading branch information
kimchy committed Nov 3, 2013
1 parent d43ae3f commit 46d3c29
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Expand Up @@ -245,7 +245,7 @@ public BulkProcessor add(BytesReference data, boolean contentUnsafe, @Nullable S
}

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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/elasticsearch/action/bulk/BulkRequest.java
Expand Up @@ -234,17 +234,17 @@ public BulkRequest add(byte[] data, int from, int length, boolean contentUnsafe,
* 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();
Expand Down Expand Up @@ -275,7 +275,7 @@ public BulkRequest add(BytesReference data, boolean contentUnsafe, @Nullable Str
String index = defaultIndex;
String type = defaultType;
String id = null;
String routing = null;
String routing = defaultRouting;
String parent = null;
String timestamp = null;
Long ttl = null;
Expand Down
Expand Up @@ -76,6 +76,7 @@ public void handleRequest(final RestRequest request, final RestChannel channel)
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) {
Expand All @@ -87,7 +88,7 @@ public void handleRequest(final RestRequest request, final RestChannel channel)
}
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);
Expand Down

0 comments on commit 46d3c29

Please sign in to comment.