An elasticsearch HTTP client built to be flexible, intelligent, and informative. easy-elasticsearch
has a built in query builder to ease the pain of generating the proper JSON.
$ npm install easy-elasticsearch
var elastic = require('easy-elasticsearch');
// Initialize the client with options
elastic.configure({
hostname : 'localhost',
port : 9200
});
// A sample document to index
var doc = { field : 'data' };
elastic.index('myIndex', 'myType', 'docID', doc, function(err, data) {
// Check err...
});
Additionally, we can bake the index, type, and even ID right into the configuration:
// Initialize the client with options
elastic.configure({
hostname : 'localhost',
port : 9200,
index : 'myIndex',
type : 'myType',
id : 'docID'
});
elastic.index(doc, function(err, data) {
// Check err...
});
Make as many easy-elasticsearch
clients as needed:
var Elastic = require('elasticsearch-client').Client;
// Initialize the client with options
var cluster = new Elastic().configure({
hostname : 'localhost',
port : 9200
});
var index = new Elastic().configure({
hostname : 'otherhost',
port : 9200,
index : 'myIndex'
});
index(index, type, id)
index(index, type)
delete(index, type, id)
get(index, type, id)
get(index, id)
head(index, type, id)
head(index, id)
multiGet(index, type)
multiGet(index)
multiGet()
update(index, type, id)
search(index, type)
search(index)
search()
multiSearch(index, type)
multiSearch(index)
multiSearch()
percolator(index, name)
percolate(index, type)
bulk(index, type)
bulk(index)
bulk()
count(index, type)
count(index)
count()
deleteByQuery(index, type)
deleteByQuery(index)
moreLikeThis(index, type, id)
validate(index, type)
validate(index)
explain(index, type, id)
aliases()
analyze(index)
analyze()
createIndex(index)
deleteIndex(index)