Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong type for bulk updates and deletes on closed index #9821

Closed
robx opened this issue Feb 23, 2015 · 1 comment · Fixed by #12060
Closed

wrong type for bulk updates and deletes on closed index #9821

robx opened this issue Feb 23, 2015 · 1 comment · Fixed by #12060
Assignees
Labels
>bug :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. good first issue low hanging fruit

Comments

@robx
Copy link

robx commented Feb 23, 2015

$ curl -XDELETE localhost:9200/test; echo
{"error":"IndexMissingException[[test] missing]","status":404}
$ curl -XPUT localhost:9200/test/test/1 -d '{"title": "test document"}'; echo
{"_index":"test","_type":"test","_id":"1","_version":1,"created":true}
$ curl -XPOST localhost:9200/test/_close; echo
{"acknowledged":true}
$ curl -XPOST localhost:9200/_bulk -d '{"update" : {"_index": "test", "_type": "type1", "_id": "1"}}
> {"doc": {"field1": "value1"}}
> '; echo
{"took":1,"errors":true,"items":[{"index":{"_index":"test","_type":"type1","_id":"1","status":403,"error":"IndexClosedException[[test] closed]"}}]} 

The key should be update instead of index. Similar things happen for deletes. The fix against current master is trivial:

diff --git a/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java b/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java
index 6e48349..ffd49df 100644
--- a/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java
+++ b/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java
@@ -168,13 +168,13 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
         } else if (request instanceof DeleteRequest) {
             DeleteRequest deleteRequest = (DeleteRequest) request;
             if (index.equals(deleteRequest.index())) {
-                responses.set(idx, new BulkItemResponse(idx, "index", new BulkItemResponse.Failure(deleteRequest.index(), deleteRequest.type(), deleteRequest.id(), e)));
+                responses.set(idx, new BulkItemResponse(idx, "delete", new BulkItemResponse.Failure(deleteRequest.index(), deleteRequest.type(), deleteRequest.id(), e)));
                 return true;
             }
         } else if (request instanceof UpdateRequest) {
             UpdateRequest updateRequest = (UpdateRequest) request;
             if (index.equals(updateRequest.index())) {
-                responses.set(idx, new BulkItemResponse(idx, "index", new BulkItemResponse.Failure(updateRequest.index(), updateRequest.type(), updateRequest.id(), e)));
+                responses.set(idx, new BulkItemResponse(idx, "update", new BulkItemResponse.Failure(updateRequest.index(), updateRequest.type(), updateRequest.id(), e)));
                 return true;
             }
         } else {

However, why is the type reported at all? Is it allowed to differ? Could there be multiple responses to a single action?

@clintongormley
Copy link

Hi @robx

Thanks for reporting. Would you be up for sending a PR?

cbuescher added a commit to cbuescher/elasticsearch that referenced this issue Jul 6, 2015
When a bulk request fails on a Delete or Update request, the BulkItemResponse
reports incorrect "index" operation in the response. This PR fixes this
for the case of closed indices as reported in elastic#9821 but also for
other failures and adds tests for the two cases covered.

Closes elastic#9821
@cbuescher cbuescher removed the help wanted adoptme label Jul 6, 2015
@lcawl lcawl added :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. and removed :Bulk labels Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. good first issue low hanging fruit
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants