Lightweight Scala Elasticsearch client implemented using Elasticsearch REST API.
- Speed up unit testing when using Spark
- Enable switching between Spark execution engine and Scala collections depending on use case, especially size of data without changing implementation
"com.github.piotr-kalanski" % "es-client_2.11" % "0.2.0"
or
<dependency>
<groupId>com.github.piotr-kalanski</groupId>
<artifactId>es-client_2.11</artifactId>
<version>0.2.0</version>
</dependency>
import com.datawizards.esclient.repository.ElasticsearchRepositoryImpl
val repository = new ElasticsearchRepositoryImpl("http://localhost:9200")
val mapping =
"""{
| "mappings" : {
| "Person" : {
| "properties" : {
| "name" : {"type" : "string"},
| "age" : {"type" : "integer"}
| }
| }
| }
|}""".stripMargin
val indexName = "persontest"
repository.createIndex(indexName, mapping)
repository.indexExists(indexName)
repository.deleteIndex(indexName)
case class Person(name: String, age: Int)
repository.write("people", "person", "1", Person("p1", 20))
repository.read[Person]("people", "person", "1")