Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Raise error during bulk POST if an index document with identical _id already exists?

I can see that for non-bulk PUT operations this functionality exists, for the _id field, using "op_type" as explained in the API.

So I tried this URL:

https://localhost:9200/my_index/_bulk/?op_type=create

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

and also

https://localhost:9200/my_index/_bulk?op_type=create

Both failed:

"error": {
    "reason": "request [/my_index/_bulk/] contains unrecognized parameter: [op_type]",

Is there any way to accomplish this? The request body is the bulk string itself and the method is POST.

>Solution :

You just need to use create instead of index in _bulk

DELETE test

POST test/_bulk?refresh
{"create": {"_id": "foo"}}
{"test": 1}
{"create": {"_id": "foo"}}
{"test": 2}

POST test/_search
{
  "query": {
    "match_all": {}
  }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading