Skip to content

Commit 1262ab2

Browse files
authored
[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.
1 parent 4e43ede commit 1262ab2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearningFeatureSet.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.elasticsearch.common.Nullable;
2525
import org.elasticsearch.common.inject.Inject;
2626
import org.elasticsearch.env.Environment;
27+
import org.elasticsearch.index.query.QueryBuilders;
2728
import org.elasticsearch.ingest.IngestStats;
2829
import org.elasticsearch.license.XPackLicenseState;
2930
import org.elasticsearch.plugins.Platforms;
@@ -39,6 +40,7 @@
3940
import org.elasticsearch.xpack.core.ml.action.GetJobsStatsAction;
4041
import org.elasticsearch.xpack.core.ml.datafeed.DatafeedState;
4142
import org.elasticsearch.xpack.core.ml.dataframe.DataFrameAnalyticsState;
43+
import org.elasticsearch.xpack.core.ml.inference.TrainedModelConfig;
4244
import org.elasticsearch.xpack.core.ml.inference.persistence.InferenceIndexConstants;
4345
import org.elasticsearch.xpack.core.ml.job.config.Job;
4446
import org.elasticsearch.xpack.core.ml.job.config.JobState;
@@ -351,6 +353,8 @@ public void execute(ActionListener<Usage> listener) {
351353
addInferenceIngestUsage(response, inferenceUsage);
352354
SearchRequestBuilder requestBuilder = client.prepareSearch(InferenceIndexConstants.INDEX_PATTERN)
353355
.setSize(0)
356+
.setQuery(QueryBuilders.boolQuery()
357+
.filter(QueryBuilders.termQuery(InferenceIndexConstants.DOC_TYPE.getPreferredName(), TrainedModelConfig.NAME)))
354358
.setTrackTotalHits(true);
355359
ClientHelper.executeAsyncWithOrigin(client.threadPool().getThreadContext(),
356360
ClientHelper.ML_ORIGIN,

0 commit comments

Comments
 (0)