Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] [ML] Fixes total hits count for distribution chart normalization. #31134

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion x-pack/plugins/ml/public/services/results_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,7 @@ function getEventDistributionData(
}

const body = {
track_total_hits: true,
query: {
// using function_score and random_score to get a random sample of documents.
// otherwise all documents would have the same score and the sampler aggregation
Expand Down Expand Up @@ -1524,7 +1525,7 @@ function getEventDistributionData(
// Because of the sampling, results of metricFunctions which use sum or count
// can be significantly skewed. Taking into account totalHits we calculate a
// a factor to normalize results for these metricFunctions.
const totalHits = _.get(resp, ['hits', 'total'], 0);
const totalHits = _.get(resp, ['hits', 'total', 'value'], 0);
const successfulShards = _.get(resp, ['_shards', 'successful'], 0);

let normalizeFactor = 1;
Expand Down