Skip to content

Commit b7aa27a

Browse files
authored
[ML] Do not fetch source when finding index of last state docs (#85334) (#85344)
There are two places where the ML code needs to find out which index in the rolling sequence of state indices the previous state document is in. Previously the search to do this was needlessly retrieving _source, which wastes memory. The change tells the two searches not to fetch _source, only the metadata.
1 parent 70d719e commit b7aa27a

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

docs/changelog/85334.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 85334
2+
summary: Do not fetch source when finding index of last state docs
3+
area: Machine Learning
4+
type: bug
5+
issues: []

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersister.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ private static SearchRequest buildQuantilesDocIdSearch(String quantilesDocId) {
341341
return new SearchRequest(AnomalyDetectorsIndex.jobStateIndexPattern()).allowPartialSearchResults(false)
342342
.source(
343343
new SearchSourceBuilder().size(1)
344+
.fetchSource(false)
344345
.trackTotalHits(false)
345346
.query(new BoolQueryBuilder().filter(new IdsQueryBuilder().addIds(quantilesDocId)))
346347
);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ private String getConcreteIndexOrWriteAlias(String documentId) {
224224
SearchRequest searchRequest = new SearchRequest(AnomalyDetectorsIndex.jobStateIndexPattern()).allowPartialSearchResults(false)
225225
.source(
226226
new SearchSourceBuilder().size(1)
227+
.fetchSource(false)
227228
.trackTotalHits(false)
228229
.query(new BoolQueryBuilder().filter(new IdsQueryBuilder().addIds(documentId)))
229230
);

0 commit comments

Comments
 (0)