Skip to content

Conversation

@Zeegaan
Copy link
Member

@Zeegaan Zeegaan commented Dec 2, 2025

This is a working progress, but it aims to resolve #10

Problem

Index rebuilds can be slow because field values need to be calculated for every piece of content. This involves property value handlers, data collection services, and various transformations - all of which are computationally expensive when performed across thousands of documents.

Solution

Persist the calculated IndexField[] data to a database table (umbSearchDocuments) when content is indexed. During index rebuilds, this cached data can be reused instead of recalculating fields from scratch.

A useDatabase parameter controls this behavior:

  • useDatabase: true (default) - Use cached fields from database if available
  • useDatabase: false - Ignore cached data and recalculate fields fresh

When content types are modified (properties added/removed), the system automatically passes useDatabase: false to ensure stale cached data isn't used.

What's Been Done

Database Layer

  • Added Document model for persisted index data (Models/Persistence/Document.cs)
  • Added DocumentDto for database mapping
  • Implemented IDocumentRepository and DocumentRepository with CRUD operations
  • Added IDocumentService and DocumentService as the service layer
  • Created database migration CustomPackageMigration to create the umbSearchDocuments table

Content Change Strategies

  • Refactored DraftContentChangeStrategy to persist fields on index and use cached data on rebuild
  • Refactored PublishedContentChangeStrategy with the same persistence pattern
  • Added GetManyAsync for batch fetching documents (optimizes descendant processing)
  • Updated IContentChangeStrategy.RebuildAsync signature to include useDatabase parameter

Index Rebuild Flow

  • Updated IContentIndexingService.Rebuild to accept useDatabase parameter
  • Modified RebuildIndexesNotificationHandler to pass useDatabase: false on content type changes and language deletion

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.

Persist index data to the DB

2 participants