Skip to content

[2.8] [MOD-12070] Extend indexing metrics (#7669)#7778

Merged
redisearch-backport-pull-request[bot] merged 1 commit into2.8from
backport-7766-to-2.8
Dec 15, 2025
Merged

[2.8] [MOD-12070] Extend indexing metrics (#7669)#7778
redisearch-backport-pull-request[bot] merged 1 commit into2.8from
backport-7766-to-2.8

Conversation

@redisearch-backport-pull-request
Copy link
Contributor

@redisearch-backport-pull-request redisearch-backport-pull-request bot commented Dec 15, 2025

Description

Backport of #7766 to 2.8.


Note

Add per-field-type indexing counters and aggregated total docs across indexes, update them during indexing, and expose via INFO MODULES with tests.

  • Metrics Updates:
    • Update global counters on successful indexing via FieldsGlobalStats_UpdateFieldDocsIndexed in src/document.c (fulltextPreprocessor, IndexerBulkAdd).
    • Implement FieldsGlobalStats_UpdateFieldDocsIndexed in src/info/global_stats.c and declare in src/info/global_stats.h.
    • Extend FieldsGlobalStats with per-type totals: text/tag/numeric/geo/geoshape/vectorTotalDocsIndexed and vector variant fields.
  • INFO Exposure:
    • Add search_total_indexing_ops_*_fields outputs in AddToInfo_Fields (src/info/info_redis.c).
    • Aggregate and expose search_total_num_docs_in_indexes via TotalIndexesInfo.total_num_docs_in_indexes (collected in src/info/indexes_info.c, surfaced in AddToInfo_Indexes).
  • Tests:
    • Add SA tests validating total_num_docs_in_indexes and per-field total_indexing_ops_*_fields, including multi-field docs and multi-value JSON (tests/pytests/test_info_modules.py).

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

* [MOD-12070] Extend indexing metrics (#7669)

* Total num indexed metric

* total docs indexed by field type

* test total indexed metic

* test field metric

* format tests

* remove empty line

* remove unecessary wait

* meirav comments

* more comments + change metric name

* expose and test geometry

* Unify metric

* test multi json

(cherry picked from commit b346977)

* remove no json

* remove total indexing time

(cherry picked from commit 8ea201f)
case INDEXFLD_T_GEOMETRY:
RSGlobalStats.fieldsStats.geometryTotalDocsIndexed += toAdd;
break;
}
Copy link

Choose a reason for hiding this comment

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

Bug: Stats not updated for dynamic multi-type fields

The switch statement in FieldsGlobalStats_UpdateFieldDocsIndexed compares fs->types against exact single-type values, but fs->types is a bitmask that can contain multiple flags for dynamic fields (as noted in code comments: "Only dynamic fields may be indexed as multiple index types"). When a dynamic field has combined types like INDEXFLD_T_TAG | INDEXFLD_T_NUMERIC, the switch won't match any case, so no statistics are recorded for such fields.

Fix in Cursor Fix in Web

}

// Since we are here, the indexing was successful, update the global statistics.
FieldsGlobalStats_UpdateFieldDocsIndexed(fs, 1);
Copy link

Choose a reason for hiding this comment

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

Bug: Fulltext stats updated before actual indexing completes

The stats update for fulltext fields at line 519 occurs in the preprocessor phase, after tokenization but before the actual inverted index writing happens (in writeCurEntries/writeMergedEntries). In contrast, other field types update stats in IndexerBulkAdd after their indexer functions complete. If fulltext index writing fails (e.g., index dropped during processing), the stats would have already been incremented, leading to inflated metrics. The comment "indexing was successful" is misleading since only preprocessing has completed at this point.

Fix in Cursor Fix in Web

@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.62%. Comparing base (de23195) to head (59df50b).
⚠️ Report is 2 commits behind head on 2.8.

Additional details and impacted files
@@            Coverage Diff             @@
##              2.8    #7778      +/-   ##
==========================================
- Coverage   87.63%   87.62%   -0.02%     
==========================================
  Files         203      203              
  Lines       35227    35266      +39     
==========================================
+ Hits        30871    30901      +30     
- Misses       4356     4365       +9     
Flag Coverage Δ
flow 82.03% <100.00%> (-0.22%) ⬇️
unit 42.20% <48.71%> (+<0.01%) ⬆️

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.

@lerman25 lerman25 changed the title [2.8] [2.10] [MOD-12070] Extend indexing metrics (#7669) [2.8] [MOD-12070] Extend indexing metrics (#7669) Dec 15, 2025
@redisearch-backport-pull-request redisearch-backport-pull-request bot added this pull request to the merge queue Dec 15, 2025
Merged via the queue into 2.8 with commit fe8f33f Dec 15, 2025
13 checks passed
@redisearch-backport-pull-request redisearch-backport-pull-request bot deleted the backport-7766-to-2.8 branch December 15, 2025 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant