Skip to content

Commit

Permalink
Repair ES queries when rest.action.multi.allow_explicit_index: false
Browse files Browse the repository at this point in the history
When rest.action.multi.allow_explicit_index is set to false, Kibana 4
queries fail with ElasticsearchIllegalArgumentException[explicit index
in multi get is not allowed]
This workaround fixes that.
  • Loading branch information
Asimov4 committed Mar 14, 2015
1 parent 5e234ef commit 8e1d639
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39518,31 +39518,36 @@ define('components/courier/fetch/strategy/search',['require','lodash','angular']

return {
clientMethod: 'msearch',

/**
* Flatten a series of requests into as ES request body
*
* @param {array} requests - the requests to serialize
* @return {string} - the request body
*/
reqsFetchParamsToBody: function (reqsFetchParams) {
return reqsFetchParams.map(function (fetchParams) {
var indices = _.union(reqsFetchParams.map(function (fetchParams) {
var indexList = fetchParams.index;

if (_.isFunction(_.deepGet(indexList, 'toIndexList'))) {
var timeBounds = timefilter.getBounds();
indexList = indexList.toIndexList(timeBounds.min, timeBounds.max);
}


return indexList;
}));

var bodyStr = reqsFetchParams.map(function (fetchParams) {
return angular.toJson({
index: indexList,
type: fetchParams.type,
search_type: fetchParams.search_type,
ignore_unavailable: true
})
+ '\n'
+ angular.toJson(fetchParams.body || {});
}).join('\n') + '\n';

return {bodyStr: bodyStr, indices: indices};
},

/**
Expand Down Expand Up @@ -42904,13 +42909,27 @@ define('components/courier/fetch/_call_client',['require','lodash','components/c
if (esPromise === ABORTED) {
throw ABORTED;
}

return (esPromise = es[strategy.clientMethod]({
var indices = [];
if(body.docs) {
indices = _.map(body.docs, function(v){ return v._index });
_.each(body.docs, function(v){
delete v._index;
});
} else if(body.indices) {
indices = body.indices;
body = body.bodyStr;
} else if(_.isArray(body)) {
var bodyStr = _.map(body, function(v){ return v.body }).join("\n");
indices = _.map(body, function(v){ return v.index });
body = bodyStr;
}

return es[strategy.clientMethod]({
timeout: configFile.shard_timeout,
ignore_unavailable: true,
preference: sessionId,
body: body
}));
body: body,
index: indices.join(',')
})
})
.then(function (clientResp) {
return strategy.getResponses(clientResp);
Expand Down

0 comments on commit 8e1d639

Please sign in to comment.