feat: Enhance chunk management and FAQ import functionality

- Updated chunk repository methods to support deletion of unindexed chunks and listing all FAQ chunks by knowledge ID.
- Introduced batch update functionality for chunks in the chunk service.
- Enhanced FAQ import logic to handle append and replace operations, improving efficiency and data integrity.
- Added content hash calculation for FAQ entries to facilitate quick matching and deduplication.
- Refactored related methods to streamline the import process and improve logging for better tracking of import tasks.
This commit is contained in:
wizardchen
2025-11-24 15:47:42 +08:00
parent 385108ce22
commit e56233ef11
9 changed files with 353 additions and 118 deletions
@@ -0,0 +1,17 @@
-- 000013_add_chunk_status_and_hash.down.sql
-- Rollback: Remove status and content_hash fields from chunks table
BEGIN;
-- Drop index on content_hash
DROP INDEX IF EXISTS idx_chunks_content_hash;
-- Drop content_hash column
ALTER TABLE chunks
DROP COLUMN IF EXISTS content_hash;
-- Drop status column
ALTER TABLE chunks
DROP COLUMN IF EXISTS status;
COMMIT;
@@ -0,0 +1,18 @@
-- 000013_add_chunk_status_and_hash.up.sql
-- Add status and content_hash fields to chunks table
BEGIN;
-- Add status field to track chunk processing state
ALTER TABLE chunks
ADD COLUMN IF NOT EXISTS status INT NOT NULL DEFAULT 0;
-- Add content_hash field for quick content matching (primarily for FAQ)
ALTER TABLE chunks
ADD COLUMN IF NOT EXISTS content_hash VARCHAR(64);
-- Create index on content_hash for efficient lookup
CREATE INDEX IF NOT EXISTS idx_chunks_content_hash
ON chunks(content_hash);
COMMIT;