All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sksamuel.elastic4s.requests.searches.InnerHit.scala Maven / Gradle / Ivy

There is a newer version: 8.15.4
Show newest version
package com.sksamuel.elastic4s.requests.searches

import com.sksamuel.elastic4s.requests.get.{HitField, MetaDataFields}

case class InnerHit(index: String,
                    id: String,
                    nested: Map[String, AnyRef],
                    score: Option[Double],
                    routing: String,
                    source: Map[String, AnyRef],
                    innerHits: Map[String, InnerHits],
                    highlight: Map[String, Seq[String]],
                    sort: Seq[AnyRef],
                    fields: Map[String, AnyRef]) {

  def docValueField(fieldName: String): HitField = docValueFieldOpt(fieldName).get
  def docValueFieldOpt(fieldName: String): Option[HitField] = fields.get(fieldName).map { v =>
    new HitField {
      override def values: Seq[AnyRef] = v match {
        case values: Seq[AnyRef] => values
        case value: AnyRef => Seq(value)
      }
      override def value: AnyRef = values.head
      override def name: String = fieldName
      override def isMetadataField: Boolean = MetaDataFields.fields.contains(name)
    }
  }

  // todo put back ?
//  def sourceAsString: String = SourceAsContentBuilder(source).string
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy