How to create a document where the _id has spaces (Dev Tools)

I am attempting to create a document in an index where _id has spaces. I get a parsing exception in Dev Tools. Here is the start of POST statement:

POST /label-expression/_doc/(AB_123 | CD_123)

I must have the spaces, and somehow all the other documents in the index have _ids with spaces. I tried escaping like this:

POST /label-expression/_doc/(AB_123\ |\ \CD_123)

, still got error. I would be grateful for any ideas, even if I have to do it some other way than with Dev Tools. Thank you!

May be replace spaces with %20?

And you have to use the PUT verb (instead of POST) when you want to specify an id during document creation.

Yes! that worked! Thank you sir!!

Really?? Its working fine with POST

But it should be a PUT indeed.

ok regarding PUT. What is the down side of using POST instead of PUT in this situation?

POST should not work as in that case the id is automatically generated.

PUT means put this specific resource (knowing its id)

Actually, both PUT and POST work. I really thought that you had to use PUT in this case - that's also what it says in the current Index API docs.

Just tested the following with Kibana Dev Tools (ELK Stack v8.10.4)

POST /products/_doc/76
{
  "name": "Laptop"
}

PUT /products/_doc/42
{
  "name": "Book"
}

# Both products have the specified _id
GET /products/_search

Agreed. It looks like a bug or a undocumented change... :blush:

  • PUT /<target>/_doc/<_id>
  • POST /<target>/_doc/

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.