ElasticSearch ID constraints

Gabbar picture Gabbar · Aug 29, 2012 · Viewed 8.1k times · Source

For ElasticSearch document IDs, are there any character constraints or restrictions?

I am really interested to know if forward slash '/' would cause any issues here? I have some news feeds which I would like to index. The problem is that the database that contains this data that has UID set to the URL of the news feed. Don't ask me why it was designed this way because I haven't gotten a clue.

I want to use the same identifier(URL) for ElasticSearch document. I have successfully used GUIDs, alphanumeric and numeric characters without problems.

If I can't what would be the best workaround - should i encode the entire url?

Thanks

Answer

imotov picture imotov · Aug 30, 2012

There are no constraints. Forward slashes can be used. But in order to use such id in the REST API, it has to be url encoded:

$ curl -XPUT "localhost:9200/id-test-index/rec/1+1%2F2" -d '{"field" : "one and a half"}'