# Elastic4s get a fields contents from a document using id

**URL:** <https://discuss.elastic.co/t/elastic4s-get-a-fields-contents-from-a-document-using-id/69594>\
**Category:** Elasticsearch\
**Created:** [December 20, 2016, 4:13pm UTC](https://discuss.elastic.co/t/elastic4s-get-a-fields-contents-from-a-document-using-id/69594 "2016-12-20T16:13:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RPGambit](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@RPGambit](https://discuss.elastic.co/u/RPGambit)\
**Post date:** [December 20, 2016, 4:13pm UTC](https://discuss.elastic.co/t/elastic4s-get-a-fields-contents-from-a-document-using-id/69594/1 "2016-12-20T16:13:13Z")

</div>

Hi. I am programming in scala and using elastic4s. I have an index that contains many documents each indexed using a specific unique id. How can I get the value of one of my fields: ClientId from the index using the id? I really want to know if this field exists yet or has something in it.

Thanks!

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [December 20, 2016, 6:15pm UTC](https://discuss.elastic.co/t/elastic4s-get-a-fields-contents-from-a-document-using-id/69594/2 "2016-12-20T18:15:38Z")

</div>

I don't know anything about elastic4s, but the API you want to look into is the GET API. [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html)

---

<div class="post-metadata">

**Author:** ![RPGambit](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@RPGambit](https://discuss.elastic.co/u/RPGambit)\
**Post date:** [December 20, 2016, 6:53pm UTC](https://discuss.elastic.co/t/elastic4s-get-a-fields-contents-from-a-document-using-id/69594/3 "2016-12-20T18:53:39Z")

</div>

Thank you. I'm trying to do something like:

```
// Check if we already called the Web Service API for this RunId/JobId, if not, call it
val resp: Future[RichGetResponse] = elasticSearchClient.execute {
  get ((jobId, runId)) from "elk-indexing-node/elk-indexing-group"
}

// Whenever this future comes back, check if we already got the DTO data. If not, get it and
// write it to Elasticsearch.
resp.onComplete{
  case Success(p) => {
    val d = p
    log.error(s"Already got JobDTO data and the Client is: ${d.getField("Client")} !!!")
  }

```

I keep getting the string: "Already got JobDTO data and the Client is: null !!!"

I want the data from the field "Client" which is 2

Thanks!

---

<div class="post-metadata">

**Author:** ![RPGambit](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@RPGambit](https://discuss.elastic.co/u/RPGambit)\
**Post date:** [January 6, 2017, 3:35pm UTC](https://discuss.elastic.co/t/elastic4s-get-a-fields-contents-from-a-document-using-id/69594/4 "2017-01-06T15:35:24Z")

</div>

Thank you. It doesn't appear that the version of elastic4s I am using, has the "get" API yet. I tried to go to the latest version in my build.sbt, but it gives me auth errors. No sure why. The version I am currently using in my build.sbt is:

"com.sksamuel.elastic4s" %% "elastic4s-core" % "2.3.0"

---

<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:** [February 3, 2017, 3:35pm UTC](https://discuss.elastic.co/t/elastic4s-get-a-fields-contents-from-a-document-using-id/69594/5 "2017-02-03T15:35:47Z")

</div>

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