Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/piotr-kalanski/es-client
Lightweight Scala Elasticsearch client implemented using Elasticsearch REST API.
https://github.com/piotr-kalanski/es-client
elasticsearch scala
Last synced: 29 days ago
JSON representation
Lightweight Scala Elasticsearch client implemented using Elasticsearch REST API.
- Host: GitHub
- URL: https://github.com/piotr-kalanski/es-client
- Owner: piotr-kalanski
- License: apache-2.0
- Created: 2017-06-16T15:19:48.000Z (over 7 years ago)
- Default Branch: development
- Last Pushed: 2017-07-24T18:46:39.000Z (over 7 years ago)
- Last Synced: 2024-09-27T16:01:45.918Z (about 1 month ago)
- Topics: elasticsearch, scala
- Language: Scala
- Size: 20.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# es-client
Lightweight Scala Elasticsearch client implemented using Elasticsearch REST API.
[![Build Status](https://api.travis-ci.org/piotr-kalanski/es-client.png?branch=development)](https://api.travis-ci.org/piotr-kalanski/es-client.png?branch=development)
[![codecov.io](http://codecov.io/github/piotr-kalanski/es-client/coverage.svg?branch=development)](http://codecov.io/github/piotr-kalanski/es-client/coverage.svg?branch=development)
[](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22es-client_2.11%22)
[![Stories in Ready](https://badge.waffle.io/piotr-kalanski/es-client.png?label=Ready)](https://waffle.io/piotr-kalanski/es-client)
[![License](http://img.shields.io/:license-Apache%202-red.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt)# Table of contents
- [Goals](#goals)
- [Getting started](#getting-started)
- [Examples](#examples)# Goals
- 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# Getting started
## Include dependencies
```scala
"com.github.piotr-kalanski" % "es-client_2.11" % "0.2.0"
```or
```xml
com.github.piotr-kalanski
es-client_2.11
0.2.0```
## Create Elasticsearch repository
```scala
import com.datawizards.esclient.repository.ElasticsearchRepositoryImplval repository = new ElasticsearchRepositoryImpl("http://localhost:9200")
```# Examples
## Create index
```scala
val mapping =
"""{
| "mappings" : {
| "Person" : {
| "properties" : {
| "name" : {"type" : "string"},
| "age" : {"type" : "integer"}
| }
| }
| }
|}""".stripMarginval indexName = "persontest"
repository.createIndex(indexName, mapping)
```## Check if index exists
```scala
repository.indexExists(indexName)
```## Delete index
```scala
repository.deleteIndex(indexName)
```## Writing and reading documents
```scala
case class Person(name: String, age: Int)repository.write("people", "person", "1", Person("p1", 20))
repository.read[Person]("people", "person", "1")
```