Automatically select default index if there is only one (#9707)

Backports PR #9679

**Commit 1:**
Automatically select index if only one

* Original sha: c8fc69fcff
* Authored by Lukas Olson <olson.lukas@gmail.com> on 2016-12-29T18:46:05Z
This commit is contained in:
jasper 2017-01-03 14:13:49 -05:00 committed by Matt Bargar
parent b2ffc35741
commit 82f883a70e

View file

@ -31,7 +31,13 @@ module.exports = function (opts) {
}
if (!defined && route.requireDefaultIndex) {
throw new NoDefaultIndexPattern();
// If there is only one index pattern, set it as default
if (patterns.length === 1) {
defaultId = patterns[0];
config.set('defaultIndex', defaultId);
} else {
throw new NoDefaultIndexPattern();
}
}
return notify.event('loading default index pattern', function () {