client.get: mix in source data, fix default index and type params

This commit is contained in:
2016-04-29 17:52:24 -07:00
parent 72389b65b2
commit b2781a6ccf

View File

@@ -26,10 +26,10 @@ Client.prototype.ping = function () {
return Promise.resolve(); return Promise.resolve();
}; };
Client.prototype.get = function (params = {}, source = false) { Client.prototype.get = function (params = {}, source = {}) {
if (params === elasticsearch.errors.NotFound) return elasticsearch.errors.NotFound; if (params === elasticsearch.errors.NotFound) return elasticsearch.errors.NotFound;
const _source = source || { const _source = Object.assign({
payload: { payload: {
id: 'sample-job-1', id: 'sample-job-1',
now: 'Mon Apr 25 2016 14:13:04 GMT-0700 (MST)' now: 'Mon Apr 25 2016 14:13:04 GMT-0700 (MST)'
@@ -40,11 +40,11 @@ Client.prototype.get = function (params = {}, source = false) {
attempts: 0, attempts: 0,
max_attempts: 3, max_attempts: 3,
status: 'pending' status: 'pending'
}; }, source);
return { return {
_index: params.index, _index: params.index || 'index',
_type: params.type, _type: params.type || 'type',
_id: params.id || 'AVRPRLnlp7Ur1SZXfT-T', _id: params.id || 'AVRPRLnlp7Ur1SZXfT-T',
_version: params.version || 1, _version: params.version || 1,
found: true, found: true,