24

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

Gabbar
  • 4,006
  • 7
  • 41
  • 78

2 Answers2

23

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"}'
imotov
  • 28,277
  • 3
  • 90
  • 82
  • this is what i found out after way too much messing around .. thanks! – Gabbar Aug 30 '12 at 17:02
  • Actually in the earlier versions of Elasticsearch, around v1.7, some aggregations failed calculating correctly if you used colons or underscore in your _id – WoodyDRN Dec 20 '18 at 12:29
1

Slash "/" URL encoding is broken: https://github.com/elasticsearch/elasticsearch/issues/2903

Slash "/" is no longer broken. This issue has been fixed.

aioobe
  • 413,195
  • 112
  • 811
  • 826
Ryan R.
  • 2,478
  • 5
  • 27
  • 48