Skip to content

Commit

Permalink
attempt to fix observer species count accuracy for small sizes #335
Browse files Browse the repository at this point in the history
  • Loading branch information
pleary committed Jul 7, 2022
1 parent 87d7f0d commit 57d4839
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/controllers/v1/observations_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,11 @@ ObservationsController.observationsSpeciesObserverCounts = async req => {
}
}
};
// attempting to account for inaccurate counts for queries with a small size
// see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-shard-size
if ( ( ( aggSize * 1.5 ) + 10 ) < 50 ) {
countQuery.aggs.user_taxa.terms.shard_size = 50;
}
}
countQuery.per_page = 0;
countQuery.skip_total_hits = true;
Expand Down

0 comments on commit 57d4839

Please sign in to comment.