Skip to content

Commit

Permalink
handle track_total_size on request body (#4710)
Browse files Browse the repository at this point in the history
closes #4705
  • Loading branch information
PSeitz committed Mar 11, 2024
1 parent 2c94074 commit 81e4f1b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion quickwit/quickwit-serve/src/elasticsearch_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub fn elastic_api_handlers(
///
/// When set to `Count` with an integer value `n`, the response accurately tracks the total
/// hit count that match the query up to `n` documents.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum TrackTotalHits {
/// Track the number of hits that match the query accurately.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,10 @@ fn build_request_for_es_api(

let max_hits = search_params.size.or(search_body.size).unwrap_or(10);
let start_offset = search_params.from.or(search_body.from).unwrap_or(0);
let count_hits = match search_params.track_total_hits {
let count_hits = match search_params
.track_total_hits
.or(search_body.track_total_hits)
{
None => CountHits::Underestimate,
Some(TrackTotalHits::Track(false)) => CountHits::Underestimate,
Some(TrackTotalHits::Count(count)) if count <= max_hits as i64 => CountHits::Underestimate,
Expand Down

0 comments on commit 81e4f1b

Please sign in to comment.