I am developing a Spring Boot application with elasticsearch and I am using spring data elasticsearch. I have id
field annotated with @Id
. And for the id field I am inserting a value that contains some symbols including (+) plus sign. Something like this 10245365#1245+78965
. When ever I get the data I see the (+) is replaced with a space. And the id is now 10245365#1245 78965
. So is there any fix to allow even symbols for @Id? So anybody can help me? I really appreciate that.
The problem here is that since the ID is part of the URL of the document (i.e. PUT index/_doc/id
), ES considers that everything is URL-encoded, and hence, when decoded the +
sign is replaced by a space.
What you need to do is to URL-encode your ID before sending it to ES so that the +
sign gets encoded into %2B
and then properly decoded again as +