This library offers an interface based on fs2 to stream results to / from ElasticSearch.
It provides a safe handling of the client and nice lightweight syntax to interact with the ElasticSearch high level api.
The library can be used in conjuntion with the elastic4s dsl to create queries. (You need to add elastic4s as a dependency for that).
The library is compatible with
fs2 0.10.x and
At the moment, the library supports only ElasticSearch 5.6.x and 6.x.x. I plan to support the previous 5.x.x version in the near future (feel free to open a PR).
Versioning is done with the classic MAJOR.MINOR.PATCH. You should use the same MAJOR.MINOR version as your ElasticSearch cluster and the latest PATCH version available (patch doesn't track ElasticSearch versions). The Master branch always tracks the latest version (currently
Add the following to your
libraryDependencies += "com.alessandromarrella" %% "fs2-elastic" % "fs2ElasticVersion"
For the client, use:
To import all the pipes, use:
To import the syntax, use:
Creating the client
import fs2._ import org.apache.http.HttpHost import com.alessandromarrella.fs2_elastic.Client import cats.effect.IO val client = Client.fromHosts[IO](new HttpHost("localhost", 9200))
Using the pipes
import fs2._ import com.alessandromarrella.fs2_elastic.io.all._ import org.elasticsearch.action.index.IndexRequest import org.elasticsearch.action.search.SearchRequest val indexRequest = new IndexRequest("posts", "doc", "1").source("user", "amarrella", "message", "trying out Elasticsearch") val indexResponse = client through index(request)
Using the syntax
import fs2._ import com.alessandromarrella.fs2_elastic.syntax.all._ import org.elasticsearch.action.index.IndexRequest import org.elasticsearch.action.search.SearchRequest val indexRequest = new IndexRequest("posts", "doc", "1").source("user", "amarrella", "message", "trying out Elasticsearch") val indexResponse = client.index(request)
This library has been inspired by https://github.com/fiadliel/fs2-mongodb