@scvo/router-task-elasticsearch
Advanced tools
Comparing version 0.0.11 to 0.0.12
@@ -161,3 +161,4 @@ "use strict"; | ||
case 4: | ||
if (queryTemplate.noResultsRoute && response.hits.total === 0) { | ||
if (queryTemplate.noResultsRoute && (!response.hits || !response.hits.total)) { | ||
console.log('No results route for response:', response); | ||
throw new router_1.RouteTaskError(new Error('No results'), { | ||
@@ -171,2 +172,10 @@ statusCode: 404, | ||
} | ||
else if (!response.hits || !response.hits.total) { | ||
console.log('No no results route for response', response); | ||
response.hits = { | ||
max_score: 0, | ||
hits: [], | ||
total: 0 | ||
}; | ||
} | ||
pagination = this.getPagination(query.from || 0, query.size || 10, response.hits.total); | ||
@@ -278,7 +287,5 @@ response.pagination = pagination; | ||
var noResultsRoute = queryTemplates_1[i].noResultsRoute; | ||
var pagination = _this.getPagination(paginationDetails.from, paginationDetails.size, response.hits.total); | ||
response.pagination = pagination; | ||
response.request = bulk_1[i * 2 + 1]; | ||
responseMap_1[name] = response; | ||
if (noResultsRoute && response.hits.total === 0) { | ||
if (noResultsRoute && (!response.hits || !response.hits.total)) { | ||
console.log('No results route for response', response); | ||
throw new router_1.RouteTaskError(new Error('No results'), { | ||
@@ -292,2 +299,13 @@ statusCode: 404, | ||
} | ||
else if (!response.hits || !response.hits.total) { | ||
console.log('No no results route for response', response); | ||
response.hits = { | ||
max_score: 0, | ||
hits: [], | ||
total: 0 | ||
}; | ||
} | ||
var pagination = _this.getPagination(paginationDetails.from, paginationDetails.size, response.hits.total); | ||
response.pagination = pagination; | ||
response.request = bulk_1[i * 2 + 1]; | ||
}); | ||
@@ -294,0 +312,0 @@ return [2 /*return*/, responseMap_1]; |
{ | ||
"name": "@scvo/router-task-elasticsearch", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "SCVO=>Router task for Elasticsearch", | ||
@@ -5,0 +5,0 @@ "main": "./build/index", |
@@ -107,3 +107,4 @@ /* tslint:disable:no-any */ | ||
if (queryTemplate.noResultsRoute && response.hits.total === 0) { | ||
if (queryTemplate.noResultsRoute && (!response.hits || !response.hits.total)) { | ||
console.log('No results route for response:', response); | ||
throw new RouteTaskError(new Error('No results'), { | ||
@@ -116,2 +117,9 @@ statusCode: 404, | ||
}); | ||
} else if (!response.hits || !response.hits.total) { | ||
console.log('No no results route for response', response); | ||
response.hits = { | ||
max_score: 0, | ||
hits: [], | ||
total: 0 | ||
}; | ||
} | ||
@@ -225,11 +233,6 @@ | ||
const pagination = this.getPagination( | ||
paginationDetails.from, paginationDetails.size, | ||
response.hits.total); | ||
response.pagination = pagination; | ||
response.request = bulk[i * 2 + 1]; | ||
responseMap[name] = response; | ||
if (noResultsRoute && response.hits.total === 0) { | ||
if (noResultsRoute && (!response.hits || !response.hits.total)) { | ||
console.log('No results route for response', response); | ||
throw new RouteTaskError(new Error('No results'), { | ||
@@ -242,3 +245,16 @@ statusCode: 404, | ||
}); | ||
} else if (!response.hits || !response.hits.total) { | ||
console.log('No no results route for response', response); | ||
response.hits = { | ||
max_score: 0, | ||
hits: [], | ||
total: 0 | ||
}; | ||
} | ||
const pagination = this.getPagination( | ||
paginationDetails.from, paginationDetails.size, | ||
response.hits.total); | ||
response.pagination = pagination; | ||
response.request = bulk[i * 2 + 1]; | ||
}); | ||
@@ -245,0 +261,0 @@ return responseMap; |
Sorry, the diff of this file is not supported yet
124281
9
755