Elastic4s get a fields contents from a document using id

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!

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

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!

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"

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