I am trying to pass a string of JSON data into an indexing statement like this, where inputDoc is my string of JSON:
def Update(client: ElasticClient, idx:String, `type`: String, inputDoc: String): Unit = {
val address = idx + "/" + `type`
client.execute {
index into address doc inputDoc
}
}
I'm getting a compiler error that doc cannot be resolved, I'm assuming because it is looking for either a DocumentSource or DocumentMap rather than the String I am passing.
Based on this documentation it looks to me like I should be able to pass a String that Jackson will marshall into JSON. Based on this thread though, it sounds to me like elastic4s doesn't support indexing a JSON string without creating a template for it.
My question is two-fold: 1) Is it possible to index a JSON string without creating a case class to map the data? 2) If that is possible, is it advisable? Or is that discouraged because it's preferable to know the structure of the data I'm indexing rather than just adding in a JSON string I haven't necessarily checked?
I'm working with ElasticSearch version 2.1.1. Here's my elastic4s dependency:
"com.sksamuel.elastic4s" %% "elastic4s-core" % "2.1.1"