# IDs with special characters

**URL:** <https://discuss.elastic.co/t/ids-with-special-characters/167701>\
**Category:** Elasticsearch\
**Created:** [February 9, 2019, 3:22am UTC](https://discuss.elastic.co/t/ids-with-special-characters/167701 "2019-02-09T03:22:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kjamesb](https://avatars.discourse-cdn.com/v4/letter/k/f04885/32.png) [@kjamesb](https://discuss.elastic.co/u/kjamesb)\
**Post date:** [February 9, 2019, 3:22am UTC](https://discuss.elastic.co/t/ids-with-special-characters/167701/1 "2019-02-09T03:22:32Z")

</div>

I'm setting up elasticsearch with my java spring app. When I'm attempting to get records, I'm having an issue with retrieval and it seems to be due to the ID's of my records. For example, here's an Id of a record: "GD+GGAct+-+Avg+FIN201-02-01115ce07a-e5e7-4ba3-9117-4a7a49c3df01". I'm using the RestHighLevelClient.

Using kibana, I can encode and get the record with the Dev Tools. But using the code below, neither the raw id or the encoded Id is working

```
try {
			GetRequest request = new GetRequest();
			request.index("my-index");
			request.type("record");
			request.id(URLEncoder.encode("GD+GGAct+-+Avg+FIN201-02-01115ce07a-e5e7-4ba3-9117-4a7a49c3df01"));
			GetResponse response = this.restClient.get(request, RequestOptions.DEFAULT);			
			if(response.isExists()) {
				String sourceAsString = response.getSourceAsString();
			}else {
				logger.info("response does not exists");				
			}
		}catch(IOException e) {
			logger.info("error...");
			logger.info(e.getLocalizedMessage());
		}

```

any suggestions?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 11, 2019, 4:32pm UTC](https://discuss.elastic.co/t/ids-with-special-characters/167701/2 "2019-02-11T16:32:22Z")

</div>

I just tried that in Kibana:

```auto
DELETE test
PUT test/_doc/GD+GGAct+-+Avg+FIN201-02-01115ce07a-e5e7-4ba3-9117-4a7a49c3df01
{
  "foo": "bar"
}
GET test/_doc/GD+GGAct+-+Avg+FIN201-02-01115ce07a-e5e7-4ba3-9117-4a7a49c3df01

```

This gives:

```auto
{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "GD GGAct - Avg FIN201-02-01115ce07a-e5e7-4ba3-9117-4a7a49c3df01",
  "_version" : 1,
  "_seq_no" : 0,
  "_primary_term" : 1,
  "found" : true,
  "_source" : {
    "foo" : "bar"
  }
}

```

Then this code in Java:

```auto
        RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(HttpHost.create("http://localhost:9200")));

        GetResponse getResponse = client.get(new GetRequest("test", "_doc", "GD+GGAct+-+Avg+FIN201-02-01115ce07a-e5e7-4ba3-9117" +
                "-4a7a49c3df01"), RequestOptions.DEFAULT);

        System.out.println("getResponse = " + getResponse);

        client.close();

```

It gives:

```auto
getResponse = {"_index":"test","_type":"_doc","_id":"GD GGAct - Avg FIN201-02-01115ce07a-e5e7-4ba3-9117-4a7a49c3df01","_version":1,"_seq_no":0,"_primary_term":1,"found":true,"_source":{"foo":"bar"}}

```

---

<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:** [March 11, 2019, 4:32pm UTC](https://discuss.elastic.co/t/ids-with-special-characters/167701/3 "2019-03-11T16:32:23Z")

</div>

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