score:0

Here is an answer similar to the approach from @flav, but I'll give you the structure to map to the json and how to get your end result too. First, the case classes:

case class Document2(_id:String, title:String, content:String)

case class Results(hits:HitsList)
case class HitsList(hits:List[Hit])
case class Hit(_id:String, _source:Source, highlight:Highlight)
case class Source(title:String, content:String)
case class Highlight(title:List[String])

Then, the code for parsing it and converting it:

implicit val formats = DefaultFormats
val results = json.extract[Results]
val docs2 = results.hits.hits.map{ hit => 
  Document2(hit._id, hit.highlight.title.head, hit._source.content)
}

Related Query

More Query from same tag