Giter Club home page Giter Club logo

eslight's Introduction

Elasticsearch Lightweight Client

DEPRECATED! DON'T USE THIS. USE OFFICIAL ELASTIC JAVASCRIPT CLIENT

Promise based simple client for elasticsearch.

Installing

npm install eslight

Using

ESLight = require 'eslight'

es = new ESLight('http://my-es-node-1:9200/')

(es.exec 'myindex', mytype', 'mydoc').then (res) ->
    console.log 'And the result it', res
.fail (err) ->
    console.log 'Uh oh', err

(es.exec 'PUT', 'myindex', mytype', 'mydoc', {some object...}).then (res) ->
    console.log 'And the result it', res
.fail (err) ->
    console.log 'Uh oh', err

ESLight(string, ...) or ESLight(url, ...)

The constructor takes a variable number endpoints as either string or url objects. The url object is of the kind that url.parse returns.

The endpoints will be used for round robin access to distribute load and retries if any endpoint fails.

The arguments can be one or multiple strings or one or multiple arrays of strings.

exec([verb], path part, ..., [query], [body])

[verb]

The exec method has a flexible number of arguments. The first argument can be an optional HTTP string verb, one of GET, POST, PUT, DELETE. If not provided the verb defaults to GET.

path part

There must be at least one string path part. Each path part will be joined with a /. The following examples are equivalent:

  • exec('myindex', 'mytype', 'mydoc')
  • exec('myindex/mytype', 'mydoc')
  • exec('myindex/mytype/mydoc')
  • exec('/myindex/mytype/mydoc')

[body]

The body is optional and will be submitted if the last argument is of object type. Remember that typeof null == 'object'.

exec 'PUT', 'myindex/mytype/mydoc', {some:'doc', to:'store'}

[query]

The query is optional, and will only be used if there is a body part. To have only a query and no body, the last argument must be null.

Optimistic locking as in /myindex/mytype/mydoc?version=4:

exec 'PUT', 'myindex/mytype/mydoc', {version:4}, {some:'doc', to:'store'}

Notice null in this case:

exec 'GET', 'myindex/mytype/mydoc/_search', {q:'find this'}, null

eslight's People

Contributors

algesten avatar fred-o avatar

Stargazers

 avatar

Watchers

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