Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query no matches on .kibana instead of .kibana-devnull #7286

Merged
merged 1 commit into from
Jul 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/ui/public/courier/fetch/strategy/__tests__/search.js
Original file line number Diff line number Diff line change
@@ -55,11 +55,21 @@ describe('ui/courier/fetch/strategy/search', () => {
context('when indexList is empty', () => {
beforeEach(() => reqsFetchParams[0].index = []);

it('queries .kibana-devnull instead', () => {
it('queries the kibana index (.kibana) with a must_not match_all boolean', () => {
const query = JSON.stringify({
query: {
bool: {
must_not: [
{ match_all: {} }
]
}
}
});
let value;
search.reqsFetchParamsToBody(reqsFetchParams).then(val => value = val);
$rootScope.$apply();
expect(_.includes(value, '"index":[".kibana-devnull"]')).to.be(true);
expect(_.includes(value, '"index":[".kibana"]')).to.be(true);
expect(_.includes(value, query)).to.be(true);
});
});
});
20 changes: 17 additions & 3 deletions src/ui/public/courier/fetch/strategy/search.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import angular from 'angular';

import { toJson } from 'ui/utils/aggressive_parse';

export default function FetchStrategyForSearch(Private, Promise, timefilter) {
export default function FetchStrategyForSearch(Private, Promise, timefilter, kbnIndex) {

return {
clientMethod: 'msearch',
@@ -26,6 +26,7 @@ export default function FetchStrategyForSearch(Private, Promise, timefilter) {
return indexList.toIndexList(timeBounds.min, timeBounds.max);
})
.then(function (indexList) {
let body = fetchParams.body || {};
// If we've reached this point and there are no indexes in the
// index list at all, it means that we shouldn't expect any indexes
// to contain the documents we're looking for, so we instead
@@ -35,7 +36,8 @@ export default function FetchStrategyForSearch(Private, Promise, timefilter) {
// handle that request by querying *all* indexes, which is the
// opposite of what we want in this case.
if (_.isArray(indexList) && indexList.length === 0) {
indexList.push('.kibana-devnull');
indexList.push(kbnIndex);
body = emptySearch();
}
return angular.toJson({
index: indexList,
@@ -44,7 +46,7 @@ export default function FetchStrategyForSearch(Private, Promise, timefilter) {
ignore_unavailable: true
})
+ '\n'
+ toJson(fetchParams.body || {}, angular.toJson);
+ toJson(body, angular.toJson);
});
})
.then(function (requests) {
@@ -62,3 +64,15 @@ export default function FetchStrategyForSearch(Private, Promise, timefilter) {
}
};
};

function emptySearch() {
return {
query: {
bool: {
must_not: [
{ match_all: {} }
]
}
}
};
}