Home > Mobile >  Insert into elasticsearch with an id that contains slashes
Insert into elasticsearch with an id that contains slashes

Time:09-12

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

CodePudding user response:

You need to URL-encode your ID first, i.e. the URL must look like this

host/index/ee5z4d5/54zd15zd/5zd45

I don't know Feign but this issue might provide some insights on how to solve your issue.

CodePudding user response:

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/54zd15zd/5zd45
{
  "data": "my id has some slash"
}
  • Related