Reputation: 54934
I am trying to use ElasticSearch with Play 2.3.7 Scala. I have installed elastic search, added an index, and have it up and running (tested using curl). However, I am struggling to get elastic4s to work inside of a play controller.
I have created the client using a simple remote url
val client = ElasticClient.remote("localhost", 9300)
I then try to execute on the client.
client.execute {
ElasticDsl.index.into("test/test").id(id).fields (
"title" -> title,
"uid" -> uid
)
}
This is executed inside of an Action, but I get the following error.
could not find implicit value for parameter executable: com.sksamuel.elastic4s.Executable[com.sksamuel.elastic4s.IndexDefinition,R,Q]
Upvotes: 1
Views: 1782
Reputation: 54934
This appears to be caused because I was not doing a full import of ElasticDsl as follows
import com.sksamuel.elastic4s.ElasticDsl._
but instead doing
import com.sksamuel.elastic4s.ElasticDsl
When importing the full object, it clearly invokes the companion objects, including the implicits needed.
The reason for not doing a full import, was because the DSL for elastic was clashing with the DSL for Anorm, so by extracting the Elastic code to a separate function, and using the import inside of the function definition, the ambiguity was removed and the code was able to compile.
Upvotes: 1