IDs with special characters

(Keith) #1

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();
			GetResponse response = this.restClient.get(request, RequestOptions.DEFAULT);			
			if(response.isExists()) {
				String sourceAsString = response.getSourceAsString();
			}else {"response does not exists");				
		}catch(IOException e) {"error...");;

any suggestions?

(David Pilato) #2

I just tried that in Kibana:

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:

  "_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:

        RestHighLevelClient client = new RestHighLevelClient(

        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);


It gives:

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"}}

(system) closed #3

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