-
Notifications
You must be signed in to change notification settings - Fork 119
[POS FTS] 3: Add inline FTS indexing to catalog persistence #16596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: pos/fts-2-search-rebuild
Are you sure you want to change the base?
Conversation
Adds indexProduct, indexVariation, and removeFromIndex to POSSearchIndexBuilder for per-item FTS updates within existing transactions. Refactors indexAllProducts/indexAllVariations to use these methods. Wires up inline FTS indexing in POSCatalogPersistenceService: - replaceAllCatalogData clears and rebuilds the index inline - persistIncrementalCatalogData removes old entries before re-indexing - deleteProducts removes FTS entries before deleting records Co-Authored-By: Claude Opus 4.5 <[email protected]>
Generated by 🚫 Danger |
|
|
joshheald
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tweaks to make
| /// - Parameters: | ||
| /// - siteID: The site ID to search within | ||
| /// - term: The search term | ||
| /// - db: The database to search in | ||
| /// - Returns: Total count of matching results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these to the previous PR?
| /// - Parameters: | ||
| /// - siteID: The site ID to check | ||
| /// - db: The database to check in | ||
| /// - Returns: True if rebuild is needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these to the previous PR?
| // MARK: - Inline Indexing (same transaction) | ||
|
|
||
| /// Clears the FTS index for a site. | ||
| /// - Parameters: | ||
| /// - siteID: The site ID to clear | ||
| /// - db: The database (must be called within a write transaction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these to the previous PR?
| // MARK: - Private | ||
|
|
||
| private static func buildFTSQuery(from term: String) -> String { | ||
| // Split on non-alphanumeric characters to match FTS5's unicode61 tokenizer behavior |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these to the previous PR?
| try image.insert(db, onConflict: .replace) | ||
| } | ||
|
|
||
| // Then insert join table entries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retain
| } | ||
|
|
||
| for variation in catalog.variationsToPersist { | ||
| // Delete attributes for updated variations, the remaining set will be recreated later in the save |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retain full comment below
| try image.save(db) | ||
| } | ||
|
|
||
| // Upsert new join table entries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retain
| try site?.updateChanges(db) { $0.lastCatalogIncrementalSyncDate = catalog.syncDate } | ||
| } | ||
|
|
||
| // Delete products hidden from POS when detected during incremental sync |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retain and add FTS details
|
|
||
| DDLogInfo("✅ Incremental catalog persistence complete") | ||
|
|
||
| try await grdbManager.databaseConnection.read { db in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
retain logging
| } | ||
|
|
||
| func deleteProducts(_ productIDs: [Int64], variationIDs: [Int64], siteID: Int64) async throws { | ||
| public func deleteProducts(_ productIDs: [Int64], variationIDs: [Int64], siteID: Int64) async throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public needed?

Part of: WOOMOB-2109
Merge after #16595
Description
Adds per-item indexing methods to
POSSearchIndexBuilder:indexProduct: indexes a single product (filters by eligibility internally)indexVariation: indexes a single variation with parent product name and attributesremoveFromIndex: removes a specific item from the FTS indexRefactors
indexAllProducts/indexAllVariationsto delegate to these methods.Wires up inline FTS indexing in
POSCatalogPersistenceService:replaceAllCatalogDataclears and rebuilds the index inline during full syncpersistIncrementalCatalogDataremoves old entries before re-indexing updated itemsdeleteProductsremoves FTS entries before deleting recordsTest Steps
POSSearchIndexBuilderTestsandPOSCatalogPersistenceServiceTests— all tests should passRELEASE-NOTES.txtif necessary.