|
|
@ -26,22 +26,20 @@ function setup( apiConfig, esclient, query ){ |
|
|
|
return next(); |
|
|
|
return next(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var cleanOutput = _.cloneDeep(req.clean); |
|
|
|
let cleanOutput = _.cloneDeep(req.clean); |
|
|
|
if (logging.isDNT(req)) { |
|
|
|
if (logging.isDNT(req)) { |
|
|
|
cleanOutput = logging.removeFields(cleanOutput); |
|
|
|
cleanOutput = logging.removeFields(cleanOutput); |
|
|
|
} |
|
|
|
} |
|
|
|
// log clean parameters for stats
|
|
|
|
// log clean parameters for stats
|
|
|
|
logger.info('[req]', 'endpoint=' + req.path, cleanOutput); |
|
|
|
logger.info('[req]', 'endpoint=' + req.path, cleanOutput); |
|
|
|
|
|
|
|
|
|
|
|
var renderedQuery = query(req.clean); |
|
|
|
const renderedQuery = query(req.clean); |
|
|
|
|
|
|
|
|
|
|
|
// if there's no query to call ES with, skip the service
|
|
|
|
// if there's no query to call ES with, skip the service
|
|
|
|
if (_.isUndefined(renderedQuery)) { |
|
|
|
if (_.isUndefined(renderedQuery)) { |
|
|
|
return next(); |
|
|
|
return next(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
logger.debug( '[ES req]', cmd ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// options for retry
|
|
|
|
// options for retry
|
|
|
|
// maxRetries is from the API config with default of 3
|
|
|
|
// maxRetries is from the API config with default of 3
|
|
|
|
// factor of 1 means that each retry attempt will esclient requestTimeout
|
|
|
|
// factor of 1 means that each retry attempt will esclient requestTimeout
|
|
|
@ -55,12 +53,14 @@ function setup( apiConfig, esclient, query ){ |
|
|
|
const operation = retry.operation(operationOptions); |
|
|
|
const operation = retry.operation(operationOptions); |
|
|
|
|
|
|
|
|
|
|
|
// elasticsearch command
|
|
|
|
// elasticsearch command
|
|
|
|
var cmd = { |
|
|
|
const cmd = { |
|
|
|
index: apiConfig.indexName, |
|
|
|
index: apiConfig.indexName, |
|
|
|
searchType: 'dfs_query_then_fetch', |
|
|
|
searchType: 'dfs_query_then_fetch', |
|
|
|
body: renderedQuery.body |
|
|
|
body: renderedQuery.body |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger.debug( '[ES req]', cmd ); |
|
|
|
|
|
|
|
|
|
|
|
operation.attempt((currentAttempt) => { |
|
|
|
operation.attempt((currentAttempt) => { |
|
|
|
// query elasticsearch
|
|
|
|
// query elasticsearch
|
|
|
|
searchService( esclient, cmd, function( err, docs, meta ){ |
|
|
|
searchService( esclient, cmd, function( err, docs, meta ){ |
|
|
|