我使用Scala的2.11.11一个类型,elastic4s 5.4.5和elastic4s-瑟茜5.4.5无法生成可转位包含一个地图使用自定义密钥类型
import com.sksamuel.elastic4s.ElasticDsl._
import com.sksamuel.elastic4s.TcpClient
import com.sksamuel.elastic4s.circe._
import io.circe.generic.auto._
object Test {
val client: TcpClient = ???
case class Something(a: Map[AnotherThing, Int])
case class AnotherThing(b: Int)
val smth = Something(Map.empty)
client.execute {
indexInto("index"/"type").doc(smth)
}
}
这不会编译:
could not find implicit value for evidence parameter of type com.sksamuel.elastic4s.Indexable[net.lizeo.bd4m.storage.Test.Something]
indexInto("index"/"type").doc(smth)
根据文档:
只需添加导入您所选择的库下面,然后用在那些规模implicits,你现在可以通过任何键入你喜欢的文档和一个索引将自动派生。
用于弹性4s-circe的import io.circe.generic.auto._
和import com.sksamuel.elastic4s.circe._
。
我缺少什么?
您是否尝试过使用不同的JSON编组。例如,你应该没有这样的问题。 – monkjack