From 1262ab2762e1a3aeb0cbbda007c5d536d93c2d3e Mon Sep 17 00:00:00 2001 From: Benjamin Trent Date: Fri, 13 Mar 2020 16:53:34 -0400 Subject: [PATCH] [ML] [Inference] fix number inference models returned in x-pack info call (#53540) (#53560) the ML portion of the x-pack info API was erroneously counting configuration documents and definition documents. The underlying implementation of our storage separates the two out. This PR filters the query so that only trained model config documents are counted. --- .../org/elasticsearch/xpack/ml/MachineLearningFeatureSet.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSet.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSet.java index 088d16c87e3..620e08d0779 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSet.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSet.java @@ -24,6 +24,7 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.env.Environment; +import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.ingest.IngestStats; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.plugins.Platforms; @@ -39,6 +40,7 @@ import org.elasticsearch.xpack.core.ml.action.GetDatafeedsStatsAction; import org.elasticsearch.xpack.core.ml.action.GetJobsStatsAction; import org.elasticsearch.xpack.core.ml.datafeed.DatafeedState; import org.elasticsearch.xpack.core.ml.dataframe.DataFrameAnalyticsState; +import org.elasticsearch.xpack.core.ml.inference.TrainedModelConfig; import org.elasticsearch.xpack.core.ml.inference.persistence.InferenceIndexConstants; import org.elasticsearch.xpack.core.ml.job.config.Job; import org.elasticsearch.xpack.core.ml.job.config.JobState; @@ -351,6 +353,8 @@ public class MachineLearningFeatureSet implements XPackFeatureSet { addInferenceIngestUsage(response, inferenceUsage); SearchRequestBuilder requestBuilder = client.prepareSearch(InferenceIndexConstants.INDEX_PATTERN) .setSize(0) + .setQuery(QueryBuilders.boolQuery() + .filter(QueryBuilders.termQuery(InferenceIndexConstants.DOC_TYPE.getPreferredName(), TrainedModelConfig.NAME))) .setTrackTotalHits(true); ClientHelper.executeAsyncWithOrigin(client.threadPool().getThreadContext(), ClientHelper.ML_ORIGIN,