Comparing version 0.0.5 to 0.0.6
40
index.js
@@ -23,3 +23,3 @@ | ||
* ... | ||
* }); | ||
* }, {"sort":"FIELD_NAME"}); | ||
* | ||
@@ -29,2 +29,4 @@ * @param key {string} Key to search | ||
* @param cb {function} Callback function of signature (err, resp) | ||
* @param [opt] {JSON} Additional options for search like "sort" for sorted results. | ||
* Pass options as documented in elasticsearch. | ||
*/ | ||
@@ -34,8 +36,8 @@ search: function (key, value, cb) { | ||
esq.query("query", "filtered", "query", "match", key, value); | ||
var query = esq.getQuery(); | ||
this.client.search({ | ||
index: this.index, | ||
type: this.type, | ||
body: query}, | ||
cb); | ||
var query_body = esq.getQuery(); | ||
var query = {index: this.index, type: this.type, body: query_body}; | ||
if (opt) { | ||
_.merge(query, opt); | ||
} | ||
this.client.search(query, cb); | ||
}, | ||
@@ -54,3 +56,3 @@ | ||
* ... | ||
* }); | ||
* }, {"sort":"FIELD_NAME"}); | ||
* | ||
@@ -61,4 +63,6 @@ * @param key {string} Key to search | ||
* @param cb {function} Callback function of signature (err, resp) | ||
* @param [opt] {JSON} Additional options for search like "sort" for sorted results. | ||
* Pass options as documented in elasticsearch. | ||
*/ | ||
searchLastDays: function (key, value, days, cb) { | ||
searchLastDays: function (key, value, days, cb, opt) { | ||
var esq = new Esq(); | ||
@@ -68,8 +72,8 @@ var search_days = "now-" + days.toString() + "d/d"; | ||
esq.query("query", "filtered", "filter", "range", this.time_field, "gte", search_days); | ||
var query = esq.getQuery(); | ||
this.client.search({ | ||
index: this.index, | ||
type: this.type, | ||
body: query}, | ||
cb); | ||
var query_body = esq.getQuery(); | ||
var query = {index: this.index, type: this.type, body: query_body}; | ||
if (opt) { | ||
_.merge(query, opt); | ||
} | ||
this.client.search(query, cb); | ||
}, | ||
@@ -147,6 +151,7 @@ // Helper function to pack json array compatible with ElasticSearch bulk array format | ||
* ... | ||
* }); | ||
* }, {"sort":"FIELD_NAME"}); | ||
* | ||
* @param cb {function} Callback function of signature (err, resp) | ||
* @param opt {JSON} Options for search | ||
* @param [opt] {JSON} Additional options for search like "sort" for sorted results. | ||
* Pass options as documented in elasticsearch. | ||
*/ | ||
@@ -161,3 +166,2 @@ listAll: function(cb, opt) { | ||
} | ||
console.log(query); | ||
this.client.search(query, cb ); | ||
@@ -164,0 +168,0 @@ } |
{ | ||
"name": "etk", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Elastic search tool kit.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
3153764
122782