# High-Level Rest Client | Response Issue

**URL:** <https://discuss.elastic.co/t/high-level-rest-client-response-issue/129249>\
**Category:** Elasticsearch\
**Created:** [April 24, 2018, 7:48am UTC](https://discuss.elastic.co/t/high-level-rest-client-response-issue/129249 "2018-04-24T07:48:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Divya\_Dua](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@Divya\_Dua](https://discuss.elastic.co/u/Divya_Dua)\
**Post date:** [April 24, 2018, 7:48am UTC](https://discuss.elastic.co/t/high-level-rest-client-response-issue/129249/1 "2018-04-24T07:48:50Z")

</div>

Ciao,

I am using High-level rest client to connect with Elasticsearch service and I am successfully able to insert the data in Elasticsearch.

When I am inserting the data for the first time, it is showing ' **created**' in logs, but when I receive the IndexResponse, it says ' **updated**', instead of ' **created**'.

**Here is the block of code:**

```auto
case class User(id: String, name: String, age: Int)

def insert(doc: User): Boolean = {
    val request = new IndexRequest(index_name, type_name, doc.id)
    val jsonString = Json.stringify(Json.toJson(doc))
    request.source(jsonString, XContentType.JSON)
    val indexResponse = client.index(request)

    LOGGER.info("Received Index Response" + indexResponse)
    LOGGER.info("Index Response Result -- " + indexResponse.getResult)

    if (indexResponse.getResult.equals(DocWriteResponse.Result.CREATED)) {
      LOGGER.info("User data inserted!")
      true
    } else if (indexResponse.getResult.equals(DocWriteResponse.Result.UPDATED)) {
      LOGGER.info(s"User for id ${doc.id} already exists, hence it's details are updated!")
      true
    } else {
      LOGGER.info("User data not inserted!")
      false
    }
  }  

```

**Here are the Logs for the same:**

```auto
12:46:06.963 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 >> "{"id":"10","name":"User-10","age":18}"
12:46:06.964 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.InternalIODispatch - http-outgoing-0 [ACTIVE] Request ready
12:46:06.964 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl - http-outgoing-0 127.0.0.1:55826<->127.0.0.1:9200[ACTIVE][r:w]: Event cleared [w]
12:46:07.061 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl - http-outgoing-0 127.0.0.1:55826<->127.0.0.1:9200[ACTIVE][r:r]: 282 bytes read
12:46:07.062 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 201 Created[\r][\n]"
12:46:07.062 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "Location: /user-index/user/10[\r][\n]"
12:46:07.062 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "content-type: application/json; charset=UTF-8[\r][\n]"
12:46:07.062 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "content-length: 159[\r][\n]"
12:46:07.062 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
12:46:07.062 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "{"_index":"user-index","_type":"user","_id":"10","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":1,"_primary_term":2}"
12:46:07.076 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 201 Created
12:46:07.076 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 << Location: /user-index/user/10
12:46:07.076 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 << content-type: application/json; charset=UTF-8
12:46:07.076 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 << content-length: 159
12:46:07.076 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.InternalIODispatch - http-outgoing-0 [ACTIVE(159)] Response received
12:46:07.077 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.MainClientExec - [exchange: 1] Response received HTTP/1.1 201 Created
12:46:07.088 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.InternalIODispatch - http-outgoing-0 [ACTIVE(159)] Input ready
12:46:07.088 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.MainClientExec - [exchange: 1] Consume content
12:46:07.091 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.InternalHttpAsyncClient - [exchange: 1] Connection can be kept alive indefinitely
12:46:07.095 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.MainClientExec - [exchange: 1] Response processed
12:46:07.095 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.InternalHttpAsyncClient - [exchange: 1] releasing connection
12:46:07.096 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl - http-outgoing-0 127.0.0.1:55826<->127.0.0.1:9200[ACTIVE][r:r]: Remove attribute http.nio.exchange-handler
12:46:07.096 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager - Releasing connection: [id: http-outgoing-0][route: {}->http://localhost:9200][total kept alive: 0; route allocated: 1 of 5; total allocated: 1 of 10]
12:46:07.097 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager - Connection [id: http-outgoing-0][route: {}->http://localhost:9200] can be kept alive indefinitely
12:46:07.097 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionImpl - http-outgoing-0 127.0.0.1:55826<->127.0.0.1:9200[ACTIVE][r:r]: Set timeout 0
12:46:07.098 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager - Connection released: [id: http-outgoing-0][route: {}->http://localhost:9200][total kept alive: 1; route allocated: 1 of 5; total allocated: 1 of 10]
12:46:07.106 [I/O dispatcher 1] DEBUG org.elasticsearch.client.RestClient - request [PUT http://localhost:9200/user-index/user/10?timeout=1m] returned [HTTP/1.1 201 Created]
12:46:07.107 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.InternalIODispatch - http-outgoing-0 [ACTIVE] [content length: 159; pos: 159; completed: true]
12:46:07.271 [run-main-0] INFO com.knoldus.elasticsearch.service.EsOperations - Received Index ResponseIndexResponse[index=user-index,type=user,id=10,version=1,result=updated,shards={"total":2,"successful":1,"failed":0}]
12:46:07.272 [run-main-0] INFO com.knoldus.elasticsearch.service.EsOperations - Index Response Result -- UPDATED
12:46:07.272 [run-main-0] INFO com.knoldus.elasticsearch.service.EsOperations - User for id 10 already exists, hence it's details are updated!

```

Same is happening with Delete operation. When deleting an existing user, user is deleted from elasticsearch (verified this by visualising in Kibana), but it gives ' **not\_found**' at last in DeleteResponse, instead of ' **deleted**'.

Can you help me out with this?

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [April 24, 2018, 1:20pm UTC](https://discuss.elastic.co/t/high-level-rest-client-response-issue/129249/2 "2018-04-24T13:20:58Z")

</div>

Hi @Divya_Dua,  
I tried to reproduce this with no luck. Which client version are you on, and which Elasticsearch is it sending requests to?

Thanks  
Luca

---

<div class="post-metadata">

**Author:** ![Divya\_Dua](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@Divya\_Dua](https://discuss.elastic.co/u/Divya_Dua)\
**Post date:** [April 25, 2018, 11:00am UTC](https://discuss.elastic.co/t/high-level-rest-client-response-issue/129249/3 "2018-04-25T11:00:03Z")

</div>

Hey @javanna,

That seems to be Elasticsearch version issue. I have changed it and now it is working fine.

Thank You.

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [April 25, 2018, 11:13am UTC](https://discuss.elastic.co/t/high-level-rest-client-response-issue/129249/4 "2018-04-25T11:13:07Z")

</div>

Good to know @Divya_Dua, would you mind letting us know which versions you were on, out of curiosity?

Thanks  
Luca

---

<div class="post-metadata">

**Author:** ![Divya\_Dua](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@Divya\_Dua](https://discuss.elastic.co/u/Divya_Dua)\
**Post date:** [April 26, 2018, 5:26am UTC](https://discuss.elastic.co/t/high-level-rest-client-response-issue/129249/5 "2018-04-26T05:26:23Z")

</div>

Hi @javanna,

Earlier I was using Elasticsearch 6.0.1 on local and was using dependency version 5.6.0 for both Elasticsearch and high-level rest client in the project.

But now, I have switched to the latest version 6.2.4 for both dependencies and local Elasticsearch.

Thanks,  
Divya Dua

---

<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 24, 2018, 5:26am UTC](https://discuss.elastic.co/t/high-level-rest-client-response-issue/129249/6 "2018-05-24T05:26:25Z")

</div>

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