Git Product home page Git Product logo

esclient's Introduction

Elastic Search Client for Scala

The scala client is a thin wrapper around the java client. It features:

  • Asynchronous interface
  • Based on Scala 2.10 Futures
  • Single dispatch method (execute)
  • Type-safe Request / Response pairs using 'magnet' pattern

The signature of the execute method (slightly simplified):

package  org.scalastuff.esclient
import org.elasticsearch.client.Client

implicit class ESClient(client : Client) extends AnyVal {
  def execute[Request, Response](request: Request): Future[Response]
}

Usage

 libraryDependencies += "org.scalastuff" %% "esclient" % "0.90.2"

Note that the esclient versioning is aligned with the elastic search version. This is the second esclient release based on Elastic Search version 0.90.x.

Sample

import scala.concurrent.Await
import scala.concurrent.Future
import scala.concurrent.duration.DurationInt

import org.elasticsearch.action.index.IndexRequest
import org.elasticsearch.action.index.IndexResponse
import org.elasticsearch.client.Client
import org.elasticsearch.node.NodeBuilder.nodeBuilder
import org.scalastuff.esclient._

object TestES extends App {

  val client : Client = 
    nodeBuilder.node.client
  
  val response : Future[IndexResponse] = 
    client.execute(new IndexRequest) 
  
  println("Document id: " + Await.result(response, 5 seconds).id)

  // --- or if you like ---
  val preparedResponse = client.prepareIndex.execute.future

  println("Document id: " + Await.result(preparedResponse, 5 seconds).id)
}

License

This software is released under the Apache License, Version 2.0

http://www.apache.org/licenses/LICENSE-2.0.html

esclient's People

Contributors

rditerwich avatar skytteren avatar scalastuff avatar

Stargazers

Fabien Pennequin avatar

Watchers

Fabien Pennequin avatar  avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.