Giter VIP home page Giter VIP logo

node-elastical's Introduction

Elastical

Elastical is a Node.js client library for the ElasticSearch REST API.

It's not quite finished, but what's done so far has doc comments and unit tests. Keep an eye on this repo for updates.

Installing

Latest released version:

npm install elastical

Latest dev code:

npm install https://github.com/rgrove/node-elastical/tarball/master

Documentation

Docs are available here

Basic Usage

Require elastical:

var elastical = require('elastical');

Instantiate an Elastical client that will connect to http://127.0.0.1:9200:

var client = new elastical.Client();

Or specify a custom host and port:

var client = new elastical.Client('example.com', {port: 1234});

Index a document:

// Specify the index name, document type, and document to index.
client.index('blog', 'post', {
    title: "Welcome to my stupid blog",
    body : "This is the only thing I'll ever post.",
    tags : ["welcome", "first post", "last post"]
}, function (err, res) {
    // `err` is an Error, or `null` on success.
    // `res` is the parsed ElasticSearch response data.
});

Retrieve a previously-indexed document by id:

// Specify the index and the document id.
client.get('blog', '42', function (err, doc, res) {
    // `err` is an Error, or `null` on success.
    // `doc` is the parsed document data.
    // `res` is the full parsed ElasticSearch response data.
});

Perform a search:

// Simple string query (automatically turned into a query_string query).
client.search({query: 'welcome'}, function (err, results, res) {
    // `err` is an Error, or `null` on success.
    // `results` is an object containing search hits.
    // `res` is the full parsed ElasticSearch response data.
});

// Custom query options (this is equivalent to the previous example, just
// without the magic).
client.search({
    query: {query_string: {query: 'welcome'}}
}, function (err, results, res) {
    // ...
});

See the doc comments in the source for more details on available methods and options.

Developing

Fork the git repo, clone it, then install the dev dependencies.

cd elastical
npm install

Make your changes, add tests, then run the tests to make sure nothing broke.

make test

This will run both offline and online tests. Online tests require an ElasticSearch server running at http://127.0.0.1:9200/. If you only want to run the offline tests (which don't require a server), run:

make offline-tests

Pull Requests

Before embarking on any major changes, please drop me a note first just to make sure I'm not already working on something similar. This could save us both some trouble.

Please make your changes in a topic branch and submit a pull request describing what the changes do and why I should merge them. Save time by including good offline and online tests for your changes (if you don't, I'll just ask you to add them). Thanks!

Support

Nope.

License

Copyright (c) 2012 Ryan Grove ([email protected])

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

node-elastical's People

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-elastical's Issues

Put docs on Github pages

It's really great that you have extensive docs... except it's impossible to read them unless I clone the repo and run them locally. Which I generally don't want to in the heat of working on a small change to my ES code. Just putting them on Github pages and linking to them from the README would make them much more accessible.

sudden install problem

I have been including elastical in my project with no problem this week. Now during the install process of my project or when i try to install elastical on its own i get the following npm error:

npm ERR! Error: No compatible version found: diff@'[email protected]'
npm ERR! Valid install targets:
npm ERR! ["1.0.0","1.0.1","1.0.2","1.0.3","1.0.4","1.0.5","1.0.6","1.0.7","1.0.8"]

Update documentation links

I'd like access to submit a pull request which updates all of the Client documentation links since half of them lead to 404's

Docs?

I see there is a docs folder but it's not viewable unless you clone and open in a browser. Why not host it on gh-pages?

new npm package ?

The version on npm is quite outdated compared to master .. any chance to push the next version or is master deemed unstable ? I was specifically looking for aliases which have been added just AFTER the current version was published ... they at least look stable to me...

BTW: good library so far!

Add support for Partial Updates

Following the syntax they use here by setting an existing id and wrapping the change in a {"doc": { ... }} object just replaces the existing document with a doc object now

TTL

any way of specifying the TTL through this api?

Add support for _id specification with client.index

Would like to have the option to specify an _id when creating an index.

The input could match the following:

client.index('index', 'type', 'my_id', {
     key1:"value 1",
     key2:"value 2"
}, function (err, res) {
    // `err` is an Error, or `null` on success.
    // `res` is the parsed ElasticSearch response data.
    if(err) {
        console.log(err);
    } else {
        console.log(res);
    }
});

Support url string

Currently mongoose and node-mysql support this so why not ES?

This would replace (optionally)

{
  "host": "elastic.test.com",
  "port": 9200,
  "index": "production"
}

with this (elastic can be replaced with something better)

elastic://elastic.test.com:9200/production

putRiver does not work because wrapper function mistreats its arguments

When trying to use Client#putRiver with the latest npm module (0.0.12), the command fails without error message.

The reason why it fails is that the Client.putRiver method is created by the wrapIndexMethod function (https://github.com/ramv/node-elastical/blob/master/lib/client.js#L1052) which removes the first argument from the given function.

This results in Index.putRiver called without the name parameter, because it is sliced off by the wrapIndexMethod implementation.

The arguments to putRiver are (name, config, callback), which when called becomes Index#putRiver(client, config, callback) instead of the intended Index#putRiver(client, name, config, callback).

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.