No description, website, or topics provided.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
project
src/main/scala/com/alessandromarrella/fs2_elastic
LICENSE
Readme.md
build.sbt
version.sbt

Readme.md

fs2-elastic

Latest version

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).

Compatibility

The library is compatible with fs2 1.0.x and scala 2.12.x.

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

Versioning is done with the classic ES_MAJOR.ES_MINOR.LIBRARY_VERSION You should use the same ES_MAJOR.ES_MINOR version as your ElasticSearch cluster and the latest LIBRARY_VERSION version available (this doesn't track ElasticSearch patch versions and could contain breaking changes. In case of non-breaking changes we might append a .PATCH). The Master branch always tracks the latest version.

Installation

Add the following to your build.sbt:

libraryDependencies += "com.alessandromarrella" %% "fs2-elastic" % "fs2ElasticVersion"

Usage

For the client, use: import com.alessandromarrella.fs2_elastic.Client

To import all the pipes, use: import com.alessandromarrella.fs2_elastic.io.all._

To import the syntax, use: import com.alessandromarrella.fs2_elastic.io.syntax._

Example

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)

Credits

This library has been inspired by https://github.com/fiadliel/fs2-mongodb