-
bulkInsert(data, cb)
-
Inserts Json arrays in bulk mode to the Etk client
Parameters:
Name |
Type |
Description |
data |
array
|
Array of bulk arbitrary json data |
cb |
function
|
Callback function of signature (err, resp) |
Example
elastic = require('elasticsearch');
Etk = require('etk');
var client = elastic.Client({hosts: ['localhost:9200']});
var tk = new Etk(client, {index: "myindex", type: "mytype"});
var test_array= [{foo:1, bar:2, baz: "John", "@timestamp": new Date().toISOString()},
{foo:2, bar:4, baz: "Dough", "@timestamp": new Date().toISOString()},
{foo:0, bar:5, baz: "Jane", "@timestamp": new Date().toISOString()}];
tk.bulkInsert(test_array, function (err, resp) {
...
});
-
deleteAll(cb)
-
Delete all items of Etk client
Parameters:
Name |
Type |
Description |
cb |
function
|
Callback function of signature (err, resp) |
Example
elastic = require('elasticsearch');
Etk = require('etk');
var client = elastic.Client({hosts: ['localhost:9200']});
var tk = Etk(client, {index: "myindex", type: "mytype"});
tk.deleteAll(function (err, resp) {
...
});
-
listAll(cb, opt)
-
Get all items of Etk client.
Parameters:
Name |
Type |
Argument |
Description |
cb |
function
|
|
Callback function of signature (err, resp) |
opt |
json
|
<optional>
|
Additional options for search like "sort" for sorted results.
Pass options as documented in elasticsearch. |
Example
elastic = require('elasticsearch');
Etk = require('etk');
var client = elastic.Client({hosts: ['localhost:9200']});
var tk = new Etk(client, {index: "myindex", type: "mytype"});
tk.listAll(function (err, resp) {
...
}, {"sort":"FIELD_NAME"});
-
search(key, value, cb, opt)
-
Searches the key-value pair of Etk client. Returns result to the callback
function.
Parameters:
Name |
Type |
Argument |
Description |
key |
string
|
|
Key to search |
value |
string
|
|
Value of the key |
cb |
function
|
|
Callback function of signature (err, resp) |
opt |
json
|
<optional>
|
Additional options for search like "sort" for sorted results.
Pass options as documented in elasticsearch. |
Example
elastic = require('elasticsearch');
Etk = require('etk');
var client = elastic.Client({hosts: ['localhost:9200']});
var tk = new Etk(client, {index: "myindex", type: "mytype"});
tk.search("foo", "bar", function (err, resp) {
...
}, {"sort":"FIELD_NAME"});
-
searchLastDays(key, value, days, cb, opt)
-
Searches the key-value pair for the last number of days of Etk client
Returns result to the callback function.
Parameters:
Name |
Type |
Argument |
Description |
key |
string
|
|
Key to search |
value |
string
|
|
Value of the key |
days |
number
|
|
Number of days back to search |
cb |
function
|
|
Callback function of signature (err, resp) |
opt |
json
|
<optional>
|
Additional options for search like "sort" for sorted results.
Pass options as documented in elasticsearch. |
Example
elastic = require('elasticsearch');
Etk = require('etk');
var client = elastic.Client({hosts: ['localhost:9200']});
var tk = new Etk(client, {index: "myindex", type: "mytype"});
tk.searchLastDays("foo", "bar", 10, function (err, resp) {
...
}, {"sort":"FIELD_NAME"});