Skip to content

Bulk-operations is not working if elasticsearch settings rest.action.multi.allow_explicit_index: false #870

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

Closed
Tasteful opened this issue Aug 12, 2014 · 1 comment

Comments

@Tasteful
Copy link
Contributor

To be able to access restrict the usage of ES the settings rest.action.multi.allow_explicit_index should be set to false, this will make it possible to disallow _bulk-operations where the index are included in the bulk-operations. (elastic/elasticsearch#3636)

example on current request

POST /index1/testindex/_bulk
{ "index" :  {"_index":"index1","_type":"testindex"} }
{"document-id":"1","answercount":"8"}
{ "index" :  {"_index":"index1","_type":"testindex"} }
{"document-id":"2","answercount":"32"}

the server will then respond with

{"error":"ElasticsearchIllegalArgumentException[explicit index in bulk is not allowed]","status":400}

To get this to work the request should be without the _index and _type in the body or the value should be null.

POST /index1/testindex/_bulk
{ "index" :  {"_type":"testindex"} }
{"document-id":"1","answercount":"8"}
{ "index" :  {"_index":null,"_type":"testindex"} }
{"document-id":"2","answercount":"32"}

When I look into the src of NEST the NestSerializer.SerializeBulkDescriptor-method automatic assign the index and type a value if it not already are set, this make it impossible to get them as null.

What is the best solution to solve the problem? Settings on IConnectionSettings so that automatic assigning values to the index can be turned on/off for the ElasticSearchClient, settings should be used for the bulk and multiserach operations.

@Mpdreamz
Copy link
Member

@Tasteful that ES settings is completely new to me! We should probably spot when the index/type is the same as the one provided in the url and null it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants