We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 88a8a82 commit 8e004f5Copy full SHA for 8e004f5
crates/search/src/memory_index/mod.rs
@@ -473,7 +473,14 @@ impl MemorySearchIndex {
473
if let Some(term_diff) = stats.num_terms_by_field.get_mut(field) {
474
*term_diff = term_diff
475
.checked_add_signed(*total_term_diff as i64)
476
- .context("num_terms underflow")?;
+ // Tantivy's total_num_tokens count is only approximate, so we can't guarantee this won't underflow.
477
+ .unwrap_or_else(|| {
478
+ tracing::warn!(
479
+ "num_terms underflowed for field {field:?}, added {term_diff} and \
480
+ {total_term_diff}"
481
+ );
482
+ 0
483
+ });
484
} else if field == &Field::from_field_id(SEARCH_FIELD_ID) {
485
stats
486
.num_terms_by_field
0 commit comments