override def sectionForId()

in src/main/scala/datastore/ElasticsearchRepo.scala [390:418]


  override def sectionForId(sectionId:String):Future[Option[Section]] = {
    client.execute {
      search("section")
        .query(MatchQuery("id", sectionId))
    }.flatMap(response=>{
      if(response.isError) {
        logger.error(s"Unable to query Elasticsearch for section $sectionId: ${response.error.toString}")
        Future.failed(response.error.asException)
      } else {
        Future(
          for {
            hit <- response.result.hits.hits.headOption
            raw <- RawResult(hit) match {
              case Right(r)=>Some(r)
              case Left(err)=>
                logger.error(s"$err")
                None
            }
            section <- raw.content.as[Section] match {
              case Right(s)=>Some(s)
              case Left(err)=>
                logger.error(s"$err")
                None
            }
          } yield section
        )
      }
    })
  }