not found value index error on elastic4s

你说的曾经没有我的故事 提交于 2019-12-10 21:15:48

问题


im trying to index some data to elastic search by using the elastic4s API

but im getting compile error not found: value index

this is the code , later on i will map the js object fields to the elastic search fields , but for now i just want to index a 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 the 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 the complete error

[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 in the installation process ??

or it`s something else ??

thanks miki


回答1:


Your problem is a missing import. As the documentation you linked states, you also need the following:

import com.sksamuel.elastic4s.ElasticDsl._

The ElasticDsl module is an "entry point" for elastic4s' DSLs, including the IndexDsl from where the index and into methods that you use come from.

The aforementioned import is necessary in addition to the one you do have because in Scala import statements are not recursive.



来源:https://stackoverflow.com/questions/21797007/not-found-value-index-error-on-elastic4s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!