springspring-bootelasticsearchopenfeign

Insert into elasticsearch with an id that contains slashes


Hello I am trying to insert an object into elasticsearch using it's API, the problem is that the IDs of elements that I want to insert are like this : ee5z4d5/54zd15zd/5zd45

when I sent a post request to host/index/id with a body, I got an error because the request url is host/index/ee5z4d5/54zd15zd/5zd45

I am using spring boot with feign client to comminucate with elasticsearch, and my question is how I can solve this problem


Solution

  • Tldr;

    This is not an Elastic issue but more a web issue.

    What you need to do, is encode the special char in the url.

    Look at the solution below to find out what it means.

    Solution

    POST /73690410/_doc/ee5z4d5%2F54zd15zd%2F5zd45
    {
      "data": "my id has some slash"
    }