Skip to content

[MOD-13432] Fix FULLTEXT field metric count#8037

Merged
lerman25 merged 14 commits intomasterfrom
omerl-fix-fulltext-metric-count
Jan 18, 2026
Merged

[MOD-13432] Fix FULLTEXT field metric count#8037
lerman25 merged 14 commits intomasterfrom
omerl-fix-fulltext-metric-count

Conversation

@lerman25
Copy link
Collaborator

@lerman25 lerman25 commented Jan 13, 2026

Changed search_total_indexing_ops_text_fields metric to count unique terms indexed instead of documents.

Moved the metric update call from fulltextPreprocessor() to Indexer_Add(), after writeCurEntries() completes successfully. This ensures the metric accurately reflects the number of unique terms added to the inverted index, persisting even after document deletion.


Note

Adjusts field indexing metrics to be accurate and consistent across types.

  • FULLTEXT: move metric update from fulltextPreprocessor to writeCurEntries() and increment by new unique terms (spec->stats.numTerms delta)
  • Stats API: change FieldsGlobalStats_UpdateFieldDocsIndexed to accept FieldType (was FieldSpec*); update all call sites
  • INFO metrics: clarify semantics as total indexing operations; for TEXT count unique terms, others counted per-field per-doc; ensure JSON NULLs don’t increment; multi-value JSON counts once per doc
  • Tests: remove TEXT from doc-count tests, add test_total_terms_indexed_text_fields, update overlapping-index and same-type-field cases, and add JSON NULL field coverage

Written by Cursor Bugbot for commit 29d1782. This will update automatically on new commits. Configure here.

@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.90%. Comparing base (83ef6c2) to head (29d1782).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8037      +/-   ##
==========================================
- Coverage   84.01%   83.90%   -0.12%     
==========================================
  Files         365      365              
  Lines       55097    55167      +70     
  Branches    14296    14296              
==========================================
- Hits        46292    46290       -2     
- Misses       8644     8716      +72     
  Partials      161      161              
Flag Coverage Δ
flow 84.82% <100.00%> (-0.07%) ⬇️
unit 50.75% <83.33%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

src/indexer.c Outdated

// Update global statistics for fulltext fields after successful indexing
if (aCtx->numTextFields > 0) {
FieldsGlobalStats_UpdateTextFieldDocsIndexed(aCtx->numTextFields);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to just put this in the while loop in writeCurEntries?
What is the exact metric this counter is counting? If it's the amount of entries we write for the text field, I think it can be there

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, the loop is for terms rather than for each field? We want to count docs per field

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the meaning of this metric is how many times we indexed documents for text fields..
// Total number of documents indexed by each field type
Actually by this description I would think it's something else - one increment per indexed doc, no matter the field count. I know that's not the meaning since you increment in bulkAdd, but it's a bit confusing.
Anyways, we can go with what you defined it to be, if it's the number of fields then you're right. If you wish to change to the number of index entries that would probably make a bit more sense IMHO.

@lerman25 lerman25 enabled auto-merge January 14, 2026 15:41
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

}

// Update the number of terms added for metrics
FieldsGlobalStats_UpdateFieldDocsIndexed(INDEXFLD_T_FULLTEXT, spec->stats.numTerms - prevNumTerms);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FULLTEXT metric counts new terms instead of fields indexed

High Severity

The FULLTEXT field metric now tracks new unique terms added rather than text fields indexed. spec->stats.numTerms - prevNumTerms counts only terms that are new to the index; if a term like "hello" already exists from a previous document, it won't increment the counter. This differs from other field types which increment by 1 per field in IndexerBulkAdd. A document with two text fields containing "hello" and "world" would only add 1 to the metric if "hello" was previously indexed, breaking the test expectation of +2 (per field).

Fix in Cursor Fix in Web

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly

@redisearch-backport-pull-request
Copy link
Contributor

Backport failed for 8.2, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 8.2
git worktree add -d .worktree/backport-8037-to-8.2 origin/8.2
cd .worktree/backport-8037-to-8.2
git switch --create backport-8037-to-8.2
git cherry-pick -x 4e09df11613f0369318038f8012b0b3190ab7285

@redisearch-backport-pull-request
Copy link
Contributor

Backport failed for 8.4, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 8.4
git worktree add -d .worktree/backport-8037-to-8.4 origin/8.4
cd .worktree/backport-8037-to-8.4
git switch --create backport-8037-to-8.4
git cherry-pick -x 4e09df11613f0369318038f8012b0b3190ab7285

lerman25 added a commit that referenced this pull request Jan 19, 2026
* Fix metric full text metric counting

* initialize fieldspec

* Add missing include

* remove redundant lines

* test null fields

* Don't count null text fields

* reset counter

* typo fix

* remove redudant wrapper

* Count terms indexed

* remove extra line

* test text indexing

* fix test

(cherry picked from commit 4e09df1)
lerman25 added a commit that referenced this pull request Jan 19, 2026
* Fix metric full text metric counting

* initialize fieldspec

* Add missing include

* remove redundant lines

* test null fields

* Don't count null text fields

* reset counter

* typo fix

* remove redudant wrapper

* Count terms indexed

* remove extra line

* test text indexing

* fix test

(cherry picked from commit 4e09df1)
lerman25 added a commit that referenced this pull request Jan 19, 2026
* Fix metric full text metric counting

* initialize fieldspec

* Add missing include

* remove redundant lines

* test null fields

* Don't count null text fields

* reset counter

* typo fix

* remove redudant wrapper

* Count terms indexed

* remove extra line

* test text indexing

* fix test

(cherry picked from commit 4e09df1)
lerman25 added a commit that referenced this pull request Jan 19, 2026
* Fix metric full text metric counting

* initialize fieldspec

* Add missing include

* remove redundant lines

* test null fields

* Don't count null text fields

* reset counter

* typo fix

* remove redudant wrapper

* Count terms indexed

* remove extra line

* test text indexing

* fix test

(cherry picked from commit 4e09df1)
lerman25 added a commit that referenced this pull request Jan 19, 2026
* Fix metric full text metric counting

* initialize fieldspec

* Add missing include

* remove redundant lines

* test null fields

* Don't count null text fields

* reset counter

* typo fix

* remove redudant wrapper

* Count terms indexed

* remove extra line

* test text indexing

* fix test

(cherry picked from commit 4e09df1)
lerman25 added a commit that referenced this pull request Jan 19, 2026
* Fix metric full text metric counting

* initialize fieldspec

* Add missing include

* remove redundant lines

* test null fields

* Don't count null text fields

* reset counter

* typo fix

* remove redudant wrapper

* Count terms indexed

* remove extra line

* test text indexing

* fix test

(cherry picked from commit 4e09df1)
lerman25 added a commit that referenced this pull request Jan 19, 2026
…com/RediSearch/RediSearch/issues/8037)](https://github.com/RediSearch/RediSearch/issues/8037))

* Fix metric full text metric counting

* initialize fieldspec

* Add missing include

* remove redundant lines

* test null fields

* Don't count null text fields

* reset counter

* typo fix

* remove redudant wrapper

* Count terms indexed

* remove extra line

* test text indexing

* fix test

(cherry picked from commit 4e09df1)
lerman25 added a commit that referenced this pull request Jan 19, 2026
* Fix metric full text metric counting

* initialize fieldspec

* Add missing include

* remove redundant lines

* test null fields

* Don't count null text fields

* reset counter

* typo fix

* remove redudant wrapper

* Count terms indexed

* remove extra line

* test text indexing

* fix test

(cherry picked from commit 4e09df1)
lerman25 added a commit that referenced this pull request Jan 19, 2026
* Fix metric full text metric counting

* initialize fieldspec

* Add missing include

* remove redundant lines

* test null fields

* Don't count null text fields

* reset counter

* typo fix

* remove redudant wrapper

* Count terms indexed

* remove extra line

* test text indexing

* fix test

(cherry picked from commit 4e09df1)
lerman25 added a commit that referenced this pull request Jan 19, 2026
…com/RediSearch/RediSearch/issues/8037)](https://github.com/RediSearch/RediSearch/issues/8037))

* Fix metric full text metric counting

* initialize fieldspec

* Add missing include

* remove redundant lines

* test null fields

* Don't count null text fields

* reset counter

* typo fix

* remove redudant wrapper

* Count terms indexed

* remove extra line

* test text indexing

* fix test

(cherry picked from commit 4e09df1)
lerman25 added a commit that referenced this pull request Jan 19, 2026
…com/RediSearch/RediSearch/issues/8037)](https://github.com/RediSearch/RediSearch/issues/8037))

* Fix metric full text metric counting

* initialize fieldspec

* Add missing include

* remove redundant lines

* test null fields

* Don't count null text fields

* reset counter

* typo fix

* remove redudant wrapper

* Count terms indexed

* remove extra line

* test text indexing

* fix test

(cherry picked from commit 4e09df1)
@lerman25
Copy link
Collaborator Author

/backport

@redisearch-backport-pull-request
Copy link
Contributor

Backport failed for 2.8, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 2.8
git worktree add -d .worktree/backport-8037-to-2.8 origin/2.8
cd .worktree/backport-8037-to-2.8
git switch --create backport-8037-to-2.8
git cherry-pick -x 4e09df11613f0369318038f8012b0b3190ab7285

@redisearch-backport-pull-request
Copy link
Contributor

Backport failed for 2.10, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 2.10
git worktree add -d .worktree/backport-8037-to-2.10 origin/2.10
cd .worktree/backport-8037-to-2.10
git switch --create backport-8037-to-2.10
git cherry-pick -x 4e09df11613f0369318038f8012b0b3190ab7285

@redisearch-backport-pull-request
Copy link
Contributor

Backport failed for 8.2, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 8.2
git worktree add -d .worktree/backport-8037-to-8.2 origin/8.2
cd .worktree/backport-8037-to-8.2
git switch --create backport-8037-to-8.2
git cherry-pick -x 4e09df11613f0369318038f8012b0b3190ab7285

@redisearch-backport-pull-request
Copy link
Contributor

Backport failed for 8.4, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 8.4
git worktree add -d .worktree/backport-8037-to-8.4 origin/8.4
cd .worktree/backport-8037-to-8.4
git switch --create backport-8037-to-8.4
git cherry-pick -x 4e09df11613f0369318038f8012b0b3190ab7285

redisearch-backport-pull-request bot pushed a commit that referenced this pull request Jan 19, 2026
* Fix metric full text metric counting

* initialize fieldspec

* Add missing include

* remove redundant lines

* test null fields

* Don't count null text fields

* reset counter

* typo fix

* remove redudant wrapper

* Count terms indexed

* remove extra line

* test text indexing

* fix test

(cherry picked from commit 4e09df1)
@redisearch-backport-pull-request
Copy link
Contributor

Successfully created backport PR for 8.6:

github-merge-queue bot pushed a commit that referenced this pull request Jan 19, 2026
[MOD-13432] Fix FULLTEXT field metric count ([[#8037](https://github.com/RediSearch/RediSearch/issues/8037)](https://github.com/RediSearch/RediSearch/issues/8037))

* Fix metric full text metric counting

* initialize fieldspec

* Add missing include

* remove redundant lines

* test null fields

* Don't count null text fields

* reset counter

* typo fix

* remove redudant wrapper

* Count terms indexed

* remove extra line

* test text indexing

* fix test

(cherry picked from commit 4e09df1)
github-merge-queue bot pushed a commit that referenced this pull request Jan 19, 2026
[MOD-13432] Fix FULLTEXT field metric count ([[#8037](https://github.com/RediSearch/RediSearch/issues/8037)](https://github.com/RediSearch/RediSearch/issues/8037))

* Fix metric full text metric counting

* initialize fieldspec

* Add missing include

* remove redundant lines

* test null fields

* Don't count null text fields

* reset counter

* typo fix

* remove redudant wrapper

* Count terms indexed

* remove extra line

* test text indexing

* fix test

(cherry picked from commit 4e09df1)
github-merge-queue bot pushed a commit that referenced this pull request Jan 19, 2026
[MOD-13432] Fix FULLTEXT field metric count ([[#8037](https://github.com/RediSearch/RediSearch/issues/8037)](https://github.com/RediSearch/RediSearch/issues/8037))

* Fix metric full text metric counting

* initialize fieldspec

* Add missing include

* remove redundant lines

* test null fields

* Don't count null text fields

* reset counter

* typo fix

* remove redudant wrapper

* Count terms indexed

* remove extra line

* test text indexing

* fix test

(cherry picked from commit 4e09df1)
github-merge-queue bot pushed a commit that referenced this pull request Jan 19, 2026
[MOD-13432] Fix FULLTEXT field metric count ([#8037](#8037))

* Fix metric full text metric counting

* initialize fieldspec

* Add missing include

* remove redundant lines

* test null fields

* Don't count null text fields

* reset counter

* typo fix

* remove redudant wrapper

* Count terms indexed

* remove extra line

* test text indexing

* fix test

(cherry picked from commit 4e09df1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants