All Projects → Trouva → Elasto

Trouva / Elasto

Licence: mit
DEPRECATED: Simple library to query Elasticsearch

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Elasto

Keywhiz Fs
A DEPRECATED file-system client for Keywhiz
Stars: ✭ 112 (-31.29%)
Mutual labels:  deprecated
Ticons Server Php
⛔️ REPLACED BY NODE.JS VERSION:
Stars: ✭ 127 (-22.09%)
Mutual labels:  deprecated
Httpserver.jl
DEPRECATED! Basic, non-blocking HTTP server in Julia.
Stars: ✭ 138 (-15.34%)
Mutual labels:  deprecated
Atom Esformatter
Beautify JavaScript
Stars: ✭ 113 (-30.67%)
Mutual labels:  deprecated
Go Web3
Ethereum Go Client [obsolete]
Stars: ✭ 120 (-26.38%)
Mutual labels:  deprecated
Bselect
DEPRECATED - The select decorator component that was missing for Twitter Bootstrap.
Stars: ✭ 129 (-20.86%)
Mutual labels:  deprecated
Minify
DEPRECATED A simple plugin that allows you to minify blocks of HTML, CSS, and JS inline in Craft CMS templates
Stars: ✭ 111 (-31.9%)
Mutual labels:  deprecated
Redditkit.rb
[Deprecated] A Ruby wrapper for the reddit API
Stars: ✭ 156 (-4.29%)
Mutual labels:  deprecated
Intern Only Dojo
DEPRECATED - See dojo/meta for the latest on Dojo 2
Stars: ✭ 123 (-24.54%)
Mutual labels:  deprecated
Gh
(DEPRECATED) GitHub CLI made with NodeJS
Stars: ✭ 1,701 (+943.56%)
Mutual labels:  deprecated
Mate
Deprecated: Mate manages AWS Route53 and Google CloudDNS records for your Kubernetes services and ingresses. (moved from https://github.com/zalando-incubator/mate)
Stars: ✭ 114 (-30.06%)
Mutual labels:  deprecated
Python Firebase
⛔️ [DEPRECATED] python wrapper for Firebase's REST API
Stars: ✭ 117 (-28.22%)
Mutual labels:  deprecated
Cmsplugin Filer
DEPRECATED, this project is no longer maintained, see README for more information.
Stars: ✭ 129 (-20.86%)
Mutual labels:  deprecated
Dynamodb Marshaler
Translates sane javascript objects (and JSON) into DynamoDb format and vice versa.
Stars: ✭ 112 (-31.29%)
Mutual labels:  deprecated
Vip Scanner
Deprecated: Scan all sorts of themes and files and things! Use PHPCS and the VIP coding standards instead
Stars: ✭ 143 (-12.27%)
Mutual labels:  deprecated
Python Api Client
[discontinued] Python interfaces to the Meetup Web API
Stars: ✭ 111 (-31.9%)
Mutual labels:  deprecated
React Panels
React.js panel widget with support for tabs, toolbars, buttons and customizable themes
Stars: ✭ 128 (-21.47%)
Mutual labels:  deprecated
Sphero Android Sdk
🚫 DEPRECATED REPO: Sphero™ is the amazing robotic ball ( gosphero.com ), this is the repository for the Android SDK for Sphero™. Visit dev site for more information:
Stars: ✭ 160 (-1.84%)
Mutual labels:  deprecated
Jquery Simulate Ext
jQuery simulate extended
Stars: ✭ 144 (-11.66%)
Mutual labels:  deprecated
Nexpose Client
DEPRECATED: Rapid7 Nexpose API client library written in Ruby
Stars: ✭ 134 (-17.79%)
Mutual labels:  deprecated

Elasto Circle CI

⚠️ This project is currently unmaintained

Introduction

Elasto is a simple library to query Elasticsearch.

Topics

Installation

npm install elasto

Support

If you want to use this package with Elasticsearch 0.90, you should use 1.1.2. The versions >=2.X.X will only support Elasticsearch 1.X.X.

Getting started

More infos about the config options here.

var Elasto = require('elasto');
Elasto.config({
    host: 'localhost:9200',
});

Elasto provides a simple query interface for the common usecases. You can have access to the elasticsearch.js client via Elasto.client. The client gets instantiated when you set the config with a host.

Example

All-in-one example. Find more options on API.

Elasto.query({
      index: 'development',
      type: 'tweets'
})
.near({ // documents near this location
    lat: 51.5,
    lon: -0.1467912,
    radius: 3
})
.where('name', 'London') // where name matches London
.size(2) // return only 2 documents
.from(1) // skip 1 document (searching after 1 document)
.fields('name', 'address') // return only name and address fields
.exec()
.then(function (res) { // execute
   // done!
});

API

Basic query

Elasto.query({
    index: 'development',
    type: 'tweets'
})
.exec();

Fields matching

  • .where

.where accepts two types of arguments. Either an object with the fields to match.

Elasto.query({
    index: 'development',
    type: 'tweets'
})
.where({ username: '@jack'})
.exec();

Or key value pair of arguments

Elasto.query({
    index: 'development',
    type: 'tweets'
})
.where('username', '@jack')
.exec();

Term

  • .term

Search a term.

Elasto.query({
    index: 'development',
    type: 'tweets'
})
.term('#love')
.exec();

Size

  • .size
  • .limit

Limit the size of the query.

Elasto.query({
    index: 'development',
    type: 'tweets'
})
.limit(3)
.exec();

Sort

  • .sort
  • .limit

Sorts the query by a field the size of the query.

Elasto.query({
    index: 'development',
    type: 'tweets'
})
.sort('description', 'asc')
.exec();

You can also sort by distance. It will sort based on the location field in the document.

Elasto.query({
    index: 'development',
    type: 'tweets'
})
.sort('distance', {
    lat: 51.5,
    lon: -0.1467912,
})
.exec();

Distance

  • .near

Finds documents in an area. The radius is in miles.

Elasto.query({
    index: 'development',
    type: 'tweets'
})
.near({
    lat: 51.5,
    lon: -0.1467912,
    radius: 2
})
.exec();

From

  • .from
  • .offset

Skips documents in the query.

Elasto.query({
    index: 'development',
    type: 'tweets'
})
.from(3)
.exec();

Range

  • .range

Find documents where the field matches a range.

Elasto.query({
    index: 'development',
    type: 'tweets'
})
.range('characters', [120, 150])
.exec();

You can also query the distance range. It will sort based on the location field in the document. All the distances are in miles.

Elasto.query({
    index: 'development',
    type: 'tweets'
})
.range('distance', {
    lat: 51.5,
    lon: -0.1467912,
    from: 2,
    to: 3
})
.exec();

Fields

  • .fields

Only return the specific fields.

Elasto.query({
    index: 'development',
    type: 'tweets'
})
.fields(['name', 'id'])
.exec();

Exclude

  • .exclude
  • .not

Excludes documents where the query gets matched (opposite of .where).

Elasto.query({
    index: 'development',
    type: 'tweets'
})
.not('username', '@hater666')
.exec();

Count

Count documents based on a query

Elasto.query({
    index: 'development',
    type: 'tweets'
})
.count();

Raw ElasticSearch Query

Returns the raw ElasticSearch computed by Elasto. You can directly use that object with the ElasticSearch node library (that's how Elasto is designed). Takes search or count as argument. If empty, the raw query will be search.

Elasto.query({
    index: 'development',
    type: 'tweets'
})
.raw(); 
// Returns Object
// -> { index: 'development',
//  type: 'tweets',
//  body: { query: { filtered: [Object] } } }

License

elasto is released under the MIT license. See LICENSE.txt for the complete text.

Contributors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].