回答

1

我不太清楚油滑,但我想你的數據表示爲case class實例。

在這種情況下,您可以查看模塊的Scala示例,特別是IndexTest類:https://github.com/cleverage/play2-elasticsearch/blob/master/samples/elasticsearch-scala/app/indexing/IndexTest.scala。首先,你會看到你的case class需要擴展Indexable特質。然後,您必須爲您的班級定義一個IndexableManager,用於指定要使用的ES type和用於轉換數據的Json readswrites(您可以使用基本用法的Json.reads/Json.writes宏)。

然後你可以看一下,展示了IndexableManager索引的使用示例控制器,刪除和搜索索引數據:https://github.com/cleverage/play2-elasticsearch/blob/master/samples/elasticsearch-scala/app/controllers/Application.scala