# Not able to retrieve doc using transport client but works through REST

**URL:** https://discuss.elastic.co/t/not-able-to-retrieve-doc-using-transport-client-but-works-through-rest/183006
**Category:** Elasticsearch
**Created:** [May 28, 2019, 7:20am UTC](https://discuss.elastic.co/t/not-able-to-retrieve-doc-using-transport-client-but-works-through-rest/183006 "2019-05-28T07:20:06Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Yogesh\_BG](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yogesh_bg/32/70018_2.png) [@Yogesh\_BG](https://discuss.elastic.co/u/Yogesh_BG)
#### Post date: [May 28, 2019, 7:20am UTC](https://discuss.elastic.co/t/not-able-to-retrieve-doc-using-transport-client-but-works-through-rest/183006/1 "2019-05-28T07:20:06Z")

</div>

Hi

Initially we were using ES 2.4, recently upgraded to ES 6.6, but facing an issue with specific document type.

We have a index with name _logs-2019.05.28.14_ have multiple types of data, but for simplicity we had kept one type of data and tested

sample of mappings are given below

```
{
  "order": 50, 
  "index_patterns": ["logs-*"], 
  "mappings": {
    "log": {
      "_all": {
        "enabled": false
      }, 
      "properties": {
  	    "metricType": {
          "type": "keyword"
        } .,
    "fwd_zero_wnd": {
      "type": "long", 
      "doc_values": false
    }, 
    "custom2_name": {
      "norms": false,  
      "type": "keyword", 
      "index_options": "docs"
    }, 

```

And we use transport client 6.6.0. We fire a query using client and we get empty hits. But when we take tostring of request query and execute exactly same using REST it returns the result

When we took tcp dump and see, as below

```
06:38:12.386690 IP 192.168.13.22.42760 > 192.168.13.13.9300: Flags [P.], seq 120:906, ack 121, 
win 218, options [nop,nop,TS val 470802143 ecr 470799447], length 786

..$T...4E.2h...........

.......WES..............\xC....transport_client.indices:data/read/search....logs-2019.05.28.05.logs- 
2019.05.28.06.logs-2019.05.28.07.logs-2019.05.28.08.logs-2019.05.28.09.logs- 
2019.05.28.10.logs-2019.05.28.11.logs-2019.05.28.12.logs-2019.05.28.13.logs- 
2019.05.28.14.logs-2019.05.28.15.logs-2019.05.28.16.logs-2019.05.28.17.logs- 
2019.05.28.18.logs-2019.05.28.19.logs-2019.05.28.20.logs-2019.05.28.21.logs- 
2019.05.28.21.errors-2019.05.28.errors- 
2019.05.28................bool?......range?.....ts....j..0.....k.r.J......match?....
 
metricType. cgn_l4_pc..2..........bool?........bool?........match?.... accountId.$fd457d5e-7ef9-11e9- 
 9cd1-6a9aaf215cbe..2.............bool?........match?....

account_id.$fd457d5e-7ef9-11e9-9cd1-6a9aaf215cbe..2................1.......................logs.............

06:38:12.398964 IP 192.168.13.13.9300 > 192.168.13.22.42760: Flags [P.], seq 121:167, ack 906, 
win 220, options [nop,nop,TS val 470802156 ecr 470802143], length 46

.$T..E.2h...F...........

........ES...(..........\xC.........................

06:38:12.399036 IP 192.168.13.22.42760 > 192.168.13.13.9300: Flags [.], ack 167, win 218, options 
  [nop,nop,TS val 470802156 ecr 470802156], length 0

..$T...FE.2............

........

06:38:14.686521 IP 192.168.13.22.42774 > 192.168.13.13.9300: Flags [P.], seq 120:126, ack 121, 
win 209, options [nop,nop,TS val 470804443 ecr 470799444], length 6

..$T++....O............

.......TES....

```

And when we look at logs there are no exception or anything

And we have enabled trace and output is as below

```
       [2019-05-28T07:18:13,143][TRACE][o.e.t.TransportLogger] [metrics-datastore-0] Netty4TcpChannel{localAddress=/192.168.13.13:9300, remoteAddress=/192.168.13.22:42760} [length: 786, request id: 1386, type: request, version: 6.6.0, action: indices:data/read/search] READ: 786B
  [2019-05-28T07:18:13,143][TRACE][o.e.t.T.tracer] [metrics-datastore-0] [1386][indices:data/read/search] received request
  [2019-05-28T07:18:13,144][TRACE][o.e.t.T.tracer] [metrics-datastore-0] [39087][indices:data/read/search[phase/query]] sent to [{metrics-datastore-0}{dJ4qfA01SUidhL51vWsg2g}{PHzNYxFbSyC4OlqFuz9row}{192.168.13.13}{192.168.13.13:9300}{ml.machine_memory=126569361408, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}] (timeout: [null])
  [2019-05-28T07:18:13,144][TRACE][o.e.t.T.tracer] [metrics-datastore-0] [39087][indices:data/read/search[phase/query]] received request
  [2019-05-28T07:18:13,144][TRACE][o.e.t.T.tracer] [metrics-datastore-0] [39088][indices:data/read/search[phase/query]] sent to [{metrics-datastore-0}{dJ4qfA01SUidhL51vWsg2g}{PHzNYxFbSyC4OlqFuz9row}{192.168.13.13}{192.168.13.13:9300}{ml.machine_memory=126569361408, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}] (timeout: [null])
  [2019-05-28T07:18:13,144][TRACE][o.e.t.T.tracer] [metrics-datastore-0] [39088][indices:data/read/search[phase/query]] received request
  [2019-05-28T07:18:13,144][TRACE][o.e.t.T.tracer] [metrics-datastore-0] [39089][indices:data/read/search[phase/query]] sent to [{metrics-datastore-0}{dJ4qfA01SUidhL51vWsg2g}{PHzNYxFbSyC4OlqFuz9row}{192.168.13.13}{192.168.13.13:9300}{ml.machine_memory=126569361408, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}] (timeout: [null])
  [2019-05-28T07:18:13,144][TRACE][o.e.t.T.tracer] [metrics-datastore-0] [39089][indices:data/read/search[phase/query]] received request
  [2019-05-28T07:18:13,144][TRACE][o.e.t.T.tracer] [metrics-datastore-0] [39090][indices:data/read/search[phase/query]] sent to [{metrics-datastore-0}{dJ4qfA01SUidhL51vWsg2g}{PHzNYxFbSyC4OlqFuz9row}{192.168.13.13}{192.168.13.13:9300}{ml.machine_memory=126569361408, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}] (timeout: [null])
  [2019-05-28T07:18:13,144][TRACE][o.e.t.T.tracer] [metrics-datastore-0] [39090][indices:data/read/search[phase/query]] received request
  [2019-05-28T07:18:13,145][TRACE][o.e.t.T.tracer] [metrics-datastore-0] [39091][indices:data/read/search[phase/query]] sent to [{metrics-datastore-0}{dJ4qfA01SUidhL51vWsg2g}{PHzNYxFbSyC4OlqFuz9row}{192.168.13.13}{192.168.13.13:9300}{ml.machine_memory=126569361408, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}] (timeout: [null])
  [2019-05-28T07:18:13,145][TRACE][o.e.t.T.tracer] [metrics-datastore-0] [39091][indices:data/read/search[phase/query]] received request
  [2019-05-28T07:18:13,146][DEBUG][o.e.x.s.a.a.OptOutQueryCache] [metrics-datastore-0] [logs-2019.05.28.14] not opting out of the query cache; authorization is not allowed
  [2019-05-28T07:18:13,146][DEBUG][o.e.x.s.a.a.OptOutQueryCache] [metrics-datastore-0] [logs-2019.05.28.14] not opting out of the query cache; authorization is not allowed
  [2019-05-28T07:18:13,147][TRACE][o.e.t.T.tracer] [metrics-datastore-0] [39087][indices:data/read/search[phase/query]] sent response
  [2019-05-28T07:18:13,147][TRACE][o.e.t.T.tracer] [metrics-datastore-0] [39087][indices:data/read/search[phase/query]] received response from [{metrics-datastore-0}{dJ4qfA01SUidhL51vWsg2g}{PHzNYxFbSyC4OlqFuz9row}{192.168.13.13}{192.168.13.13:9300}{ml.machine_memory=126569361408, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}]
  [2019-05-28T07:18:13,147][TRACE][o.e.t.T.tracer] [metrics-datastore-0] [39088][indices:data/read/search[phase/query]] sent response
```

---

<div class="post-metadata">

### Author: ![Yogesh\_BG](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yogesh_bg/32/70018_2.png) [@Yogesh\_BG](https://discuss.elastic.co/u/Yogesh_BG)
#### Post date: [May 28, 2019, 7:29am UTC](https://discuss.elastic.co/t/not-able-to-retrieve-doc-using-transport-client-but-works-through-rest/183006/2 "2019-05-28T07:29:28Z")

</div>

REST request is

```
curl -XPOST 'localhost:9200/logs-2019.05.28.14/_search?pretty' -H 'Content-Type: application/json' -d '
{
      "from": 0,
      "size": 1,
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "ts": {
              "from": 1559002627103,
              "to": 1559092627103,
              "include_lower": true,
              "include_upper": true,
              "boost": 1.0
            }
          }
        }
      ]
    }
  }
}
'

```

and i get the result

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [May 29, 2019, 7:18am UTC](https://discuss.elastic.co/t/not-able-to-retrieve-doc-using-transport-client-but-works-through-rest/183006/3 "2019-05-29T07:18:13Z")

</div>

can you share the java code snippet as well?

---

<div class="post-metadata">

### Author: ![Yogesh\_BG](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yogesh_bg/32/70018_2.png) [@Yogesh\_BG](https://discuss.elastic.co/u/Yogesh_BG)
#### Post date: [May 29, 2019, 1:05pm UTC](https://discuss.elastic.co/t/not-able-to-retrieve-doc-using-transport-client-but-works-through-rest/183006/4 "2019-05-29T13:05:04Z")

</div>

Hi i will not be able to share exact code because its spread across files. But here is the below idea

```
private TransportClient createTransportClient() {
	Settings.Builder settings = Settings.builder().put("cluster.name", appConfiguration.getDSClusterName())
			.put("client.transport.sniff", false)
			.put("client.transport.ping_timeout", appConfiguration.getPingTimeout());
	return new PreBuiltTransportClient(settings.build()); // - UpgradeChange
}

 IndicesOptions FROM_OPTIONS = IndicesOptions.fromOptions(true, true, true, true);

SearchRequestBuilder setQuery = dataStoreConnection.getTransportClient().prepareSearch().setIndices(indexName)
			.setIndicesOptions(FROM_OPTIONS).setTypes(mappingName).setQuery(filterBuilder).setFrom(from);
```

---

<div class="post-metadata">

### Author: ![Yogesh\_BG](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yogesh_bg/32/70018_2.png) [@Yogesh\_BG](https://discuss.elastic.co/u/Yogesh_BG)
#### Post date: [May 31, 2019, 3:59am UTC](https://discuss.elastic.co/t/not-able-to-retrieve-doc-using-transport-client-but-works-through-rest/183006/5 "2019-05-31T03:59:39Z")

</div>

Can anybody help me how can i get whats happening at elasticsearch wrt that document

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [June 3, 2019, 12:10pm UTC](https://discuss.elastic.co/t/not-able-to-retrieve-doc-using-transport-client-but-works-through-rest/183006/6 "2019-06-03T12:10:51Z")

</div>

Can you use the exact same index options in the rest request as well and see what happens?

Right now those search requests seem pretty different to me.

---

<div class="post-metadata">

### Author: ![Yogesh\_BG](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yogesh_bg/32/70018_2.png) [@Yogesh\_BG](https://discuss.elastic.co/u/Yogesh_BG)
#### Post date: [June 13, 2019, 4:54am UTC](https://discuss.elastic.co/t/not-able-to-retrieve-doc-using-transport-client-but-works-through-rest/183006/7 "2019-06-13T04:54:15Z")

</div>

the rest request i pasted is here exactly the one produced by java api, its the toString() on searchRequest.

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [June 13, 2019, 7:03am UTC](https://discuss.elastic.co/t/not-able-to-retrieve-doc-using-transport-client-but-works-through-rest/183006/8 "2019-06-13T07:03:22Z")

</div>

what about the indices options in your rest request?

---

<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: [July 11, 2019, 7:03am UTC](https://discuss.elastic.co/t/not-able-to-retrieve-doc-using-transport-client-but-works-through-rest/183006/9 "2019-07-11T07:03:33Z")

</div>

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