Skip to content

Commit

Permalink
Add ML associated indices (elastic#69492)
Browse files Browse the repository at this point in the history
ML's associated indices somehow got dropped from the initial Feature States PR, so this
commit adds them again.
  • Loading branch information
gwbrown committed Mar 1, 2021
1 parent 58cbb5f commit 41a590a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/


import com.avast.gradle.dockercompose.tasks.ComposePull
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
Expand All @@ -16,11 +17,12 @@ import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
import org.gradle.plugins.ide.eclipse.model.AccessRule
import org.gradle.plugins.ide.eclipse.model.ProjectDependency
import org.gradle.plugins.ide.eclipse.model.SourceFolder
import org.gradle.util.DistributionLocator
import org.gradle.util.GradleVersion

import static org.elasticsearch.gradle.util.GradleUtils.maybeConfigure
import org.gradle.plugins.ide.eclipse.model.ProjectDependency

plugins {
id 'lifecycle-base'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import org.elasticsearch.xpack.core.ml.MachineLearningField;
import org.elasticsearch.xpack.core.ml.MlConfigIndex;
import org.elasticsearch.xpack.core.ml.MlMetaIndex;
import org.elasticsearch.xpack.core.ml.MlStatsIndex;
import org.elasticsearch.xpack.core.ml.action.CloseJobAction;
import org.elasticsearch.xpack.core.ml.action.DeleteCalendarAction;
import org.elasticsearch.xpack.core.ml.action.DeleteCalendarEventAction;
Expand Down Expand Up @@ -142,7 +143,6 @@
import org.elasticsearch.xpack.core.ml.inference.MlInferenceNamedXContentProvider;
import org.elasticsearch.xpack.core.ml.inference.persistence.InferenceIndexConstants;
import org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndex;
import org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndexFields;
import org.elasticsearch.xpack.core.ml.notifications.NotificationsIndex;
import org.elasticsearch.xpack.core.template.TemplateUtils;
import org.elasticsearch.xpack.ml.action.TransportCloseJobAction;
Expand Down Expand Up @@ -343,6 +343,8 @@
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN;
import static org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndexFields.RESULTS_INDEX_PREFIX;
import static org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndexFields.STATE_INDEX_PREFIX;

public class MachineLearning extends Plugin implements SystemIndexPlugin,
AnalysisPlugin,
Expand Down Expand Up @@ -1074,7 +1076,7 @@ public static boolean allTemplatesInstalled(ClusterState clusterState) {
List<String> templateNames =
Arrays.asList(
NotificationsIndex.NOTIFICATIONS_INDEX,
AnomalyDetectorsIndexFields.STATE_INDEX_PREFIX,
STATE_INDEX_PREFIX,
AnomalyDetectorsIndex.jobResultsIndexPrefix());
for (String templateName : templateNames) {
allPresent = allPresent && TemplateUtils.checkTemplateExistsAndVersionIsGTECurrentVersion(templateName, clusterState);
Expand Down Expand Up @@ -1156,6 +1158,17 @@ public static SystemIndexDescriptor getInferenceIndexSecurityDescriptor() {
.build();
}

@Override
public Collection<String> getAssociatedIndexPatterns() {
return org.elasticsearch.common.collect.List.of(
RESULTS_INDEX_PREFIX + "*",
STATE_INDEX_PREFIX + "*",
MlStatsIndex.indexPattern(),
".ml-notifications*",
".ml-annotations*"
);
}

@Override
public String getFeatureName() {
return "machine_learning";
Expand Down

0 comments on commit 41a590a

Please sign in to comment.