Problems with an Id with a number sign

I have a document with a number sign (#) at the end of its Id.
It makes some problems.
I tried to delete it inside Kibana but no success.

Also, I tried with Java High-Level REST Client but again no success. the client delete number sign from Id before sending the request.
here is the DeleteResponse

ElasticSearch version = 6.2.3

Is it a bug?

The # sign is a reserved character in URLs, hence you need to URL-encode it (with %23) if you want to keep it at the end of your id.

# without URL-encoding
PUT channels/channel/vakilimotlagh#
{ "field1": 1 }

# with URL-encoding
PUT channels/channel/vakilimotlagh%23
{ "field2": 2 }

Then you'll see that the # is preserved in the latter document but not the former

GET channels/_search


  "hits": {
    "total": 2,
    "max_score": 1,
    "hits": [
        "_index": "channels",
        "_type": "channel",
        "_id": "vakilimotlagh",
        "_score": 1,
        "_source": { "field1": 1 }
        "_index": "channels",
        "_type": "channel",
        "_id": "vakilimotlagh#",
        "_score": 1,
        "_source": { "field2": 2 }

Note, however, that the URL-encoding is only necessary if you want to use the # sign within an URL, if you were to create your document via the _bulk API, you wouldn't need to URL-encode it. THe following would work perfectly fine and preserve the # sign in the ID.

PUT channels/channel/_bulk
{"index": {"_id": "vakilimotlagh#" }}
1 Like

Thank you so much, It's works,

Perfect, I'm glad it works for you!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.