thadc
(Timothy Clotworthy)
November 3, 2023, 7:46pm
1
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!
dadoonet
(David Pilato)
November 3, 2023, 8:14pm
2
May be replace spaces with %20?
bunste
(Stefan Bungter)
November 4, 2023, 7:39am
3
And you have to use the PUT verb (instead of POST) when you want to specify an id during document creation.
thadc
(Timothy Clotworthy)
November 4, 2023, 12:16pm
4
Yes! that worked! Thank you sir!!
thadc
(Timothy Clotworthy)
November 4, 2023, 12:17pm
5
Really?? Its working fine with POST
dadoonet
(David Pilato)
November 4, 2023, 12:36pm
6
But it should be a PUT indeed.
thadc
(Timothy Clotworthy)
November 4, 2023, 1:09pm
7
ok regarding PUT. What is the down side of using POST instead of PUT in this situation?
dadoonet
(David Pilato)
November 4, 2023, 2:28pm
8
POST should not work as in that case the id is automatically generated.
PUT means put this specific resource (knowing its id)
bunste
(Stefan Bungter)
November 4, 2023, 3:05pm
9
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
dadoonet
(David Pilato)
November 4, 2023, 10:08pm
10
Agreed. It looks like a bug or a undocumented change...
PUT /<target>/_doc/<_id>
POST /<target>/_doc/
system
(system)
Closed
December 2, 2023, 10:09pm
11
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.