# Random non-URI encoding of document \_id

**URL:** <https://discuss.elastic.co/t/random-non-uri-encoding-of-document--id/81375>\
**Category:** Elasticsearch\
**Created:** [April 5, 2017, 10:23pm UTC](https://discuss.elastic.co/t/random-non-uri-encoding-of-document--id/81375 "2017-04-05T22:23:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![billbogaiv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/billbogaiv/32/17111_2.png) [@billbogaiv](https://discuss.elastic.co/u/billbogaiv)\
**Post date:** [April 5, 2017, 10:23pm UTC](https://discuss.elastic.co/t/random-non-uri-encoding-of-document--id/81375/1 "2017-04-05T22:23:50Z")

</div>

Using a combination of NEST (v5.0.0) and ES (v5.1.2), I am experiencing random situations of non-URI encoding when indexing a document. The document Id includes a plus-sign (+):

```auto
var indexRequest = new IndexRequest<MyDocument>(myDocumentInstance, id: "a+b");
await Client.IndexAsync(indexRequest);

```

Sometimes the document `_id` in ES gets stored as-expected. Other times, the document `_id` is `a b`. The latter behavior results in having a total of two-documents. I cannot readily duplicate the problem. I've tried writing several variations of tests to try and trigger this behavior, but nothing works. Also found an older issue related to URI encoding (ref. [https://github.com/elastic/elasticsearch-net/issues/1768](https://github.com/elastic/elasticsearch-net/issues/1768)).

I _can_ manually re-create the experience when issuing a command like:

```json
POST /my-index/my-type/a+b
{
}

```

results in:

```json
{
   "_index": "my-index",
   "_type": "my-type",
   "_id": "a b",
   "_version": 1,
   "result": "created",
   "_shards": {
      "total": 2,
      "successful": 1,
      "failed": 0
   },
   "created": true
}

```

_and encoding the URI:_

```json
POST /my-index/my-type/a%2bb
{
}

```

results in:

```json
{
   "_index": "my-index",
   "_type": "my-type",
   "_id": "a+b",
   "_version": 1,
   "result": "created",
   "_shards": {
      "total": 2,
      "successful": 1,
      "failed": 0
   },
   "created": true
}

```

Anyone else ever come across this? I have since switched to underscores and no longer have a problem, but would really like to know the root-cause.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 3, 2017, 10:23pm UTC](https://discuss.elastic.co/t/random-non-uri-encoding-of-document--id/81375/2 "2017-05-03T22:23:53Z")

</div>

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