Skip to content

Commit

Permalink
[ML] Do not fetch source when finding index of last state docs (#85334)…
Browse files Browse the repository at this point in the history
… (#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.
  • Loading branch information
droberts195 committed Mar 24, 2022
1 parent 70d719e commit b7aa27a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/85334.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 85334
summary: Do not fetch source when finding index of last state docs
area: Machine Learning
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ private static SearchRequest buildQuantilesDocIdSearch(String quantilesDocId) {
return new SearchRequest(AnomalyDetectorsIndex.jobStateIndexPattern()).allowPartialSearchResults(false)
.source(
new SearchSourceBuilder().size(1)
.fetchSource(false)
.trackTotalHits(false)
.query(new BoolQueryBuilder().filter(new IdsQueryBuilder().addIds(quantilesDocId)))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ private String getConcreteIndexOrWriteAlias(String documentId) {
SearchRequest searchRequest = new SearchRequest(AnomalyDetectorsIndex.jobStateIndexPattern()).allowPartialSearchResults(false)
.source(
new SearchSourceBuilder().size(1)
.fetchSource(false)
.trackTotalHits(false)
.query(new BoolQueryBuilder().filter(new IdsQueryBuilder().addIds(documentId)))
);
Expand Down

0 comments on commit b7aa27a

Please sign in to comment.