fix: Document deletion now properly updates the stale knowledge filter source count#1936
fix: Document deletion now properly updates the stale knowledge filter source count#1936Vchen7629 wants to merge 9 commits into
Conversation
…r from crashing rest
…private helper to keep search_knowledge_filters method focused
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Warning
|
Summary
Fixes #1254 . Knowledge filter containing specific documents used to show stale source counts even though the document was deleted and would show inflated counts if more sources are added even after the page was refreshed. This is because the source count was computed from query_data.filters.data_sources, a saved snapshot of filenames that's never pruned when a document is deleted.
Demo (Before)
screen-capture.5.webm
Demo (After)
screen-capture.3.webm
Changes
search_knowledge_filtersnow computesactive_source_countper filter by checking which of itsdata_sourcesfilenames still have indexed documents (one batched OpenSearch query via the admin client, so the count is consistent for every viewer of a shared filter)build_existing_filenames_agg_bodyhelper inopensearch_queries.pyknowledge-filter-list.tsxbadge now usesactive_source_count, falling back to the old.lengthif absentknowledge-filter-panel.tsxsource dropdown now filters its selected sources against the currently-active sources before display, so its count matches toosearch_knowledge_filters