Not found error index value on elastic 4s

im trying to index some data in elastic search using elastic4s API

but im gets a compilation error not found: value index

this is the code, and then I will display the fields of js objects in the elastic search fields , but for now I just want to index the test case

import com.sksamuel.elastic4s._
def indexComment(commentList: List[JsObject]) {
val client = ElasticClient.local
for (comment <- commentList) {
   val id = comment.\("id").as[String]   
   client.execute {
     index into "posts/test" id id.toString() fields (
      "name" -> "London",
      "country" -> "United Kingdom",
      "continent" -> "Europe",
      "status" -> "Awesome")
    }

   }

   }

  }

and this is a SBT file

libraryDependencies ++= Seq( jdbc, anorm, cache, "org.webjars" %% "webjars-play" % "2.2.1", "org.webjars" % "bootstrap" % "3.1.0", "org.webjars" % "jquery" % "2.1.0-1", "com.sksamuel.elastic4s" %% "elastic4s" % "1.0.0.0"
)

and this is a complete mistake

[error] /home/mik/programing/posts/app/helper/Helper.scala:27: not found: value index [error] index into "posts/test" id id.toString() fields ( [error] ^ [error] one error found [error] (compile:compile) Compilation failed [error] Total time: 2 s, completed Feb 15, 2014 1:34:54 PM

Did I miss something during the installation process ??

or is it something else?

thanks miki

+3
source share
1 answer

The problem is the lack of imports. Since the documentation you provided states For , , you will also need the following:

import com.sksamuel.elastic4s.ElasticDsl._

ElasticDsl module " " elastic4s IndexDsl, index into, .

, , Scala .

+4

All Articles