Git Product home page Git Product logo

elastorm's Introduction

elastorm

Some handy APIs for elastic search querying. Useful if you want to get rid of elasticsearch complicated json query (will be added more APIs soon).

Installation

$ npm install elastorm

How to use

var estorm = require('elastorm');

Create a builder object

var buider = estorm({
    index: //name of index,
    limit: //number of rows that returned,
    offset: //offset,
    elastic: {
        host: //IP address,
        sniffOnStart: //[true/false],
        sniffInterval: //[true/false],
    }
});

APIs

.query(string, fields, default_operator)

Used to build the query string.

buider.query('*firstname:Micheal lastname:Jackson*', ['firstname', 'lastname'], 'AND')
.range(key, from, to)

Used to filter the results by a specific key.

buider.range('createdAt', '12/20/1985', '12/20/2015')
.view(array, viewRaw)

Used to set the fields that will return. Set viewRaw = true if you want to get the original returned from Elasticsearch.

buider.view([
            "firstname",
            "lastname",
            "email",
            "title",
            "group",
            "company",
            "permissions"
        ], true)
.sort(key, order, mode, ignore_unmapped)

Used to sort the results by a specific key.

buider.sort('createdAt', 'desc', null, true)
.group(groupname, field, output)

Used to group the results by a specific key. Output is the array of returned fields (similar to view api)

buider.group('company', 'company.raw', view)
.results(fn)

Used to get the results.

buider.results(function(res){
	//Do something with the results
})

elastorm's People

Watchers

Vincent Pham 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.