Package com.tnsai.server.rag
Class FileIndexer
java.lang.Object
com.tnsai.server.rag.FileIndexer
Server index adapter over the canonical
FileIngestionService.
Features:
- Shares discovery, ignore, detection, extraction, and chunking with declarative RAG
- Pipeline fingerprints for incremental re-indexing (content plus extractor, chunker, format, and selector identity)
- Stage-then-commit so a failed replacement never publishes a mixed generation to TF-IDF and BM25
- Reconciles deleted, renamed, previous-root, and now-skipped files
against the previous load through
FileSourceReconciler. A file that fails to read is not stale: previous chunks stay until a later complete ingest replaces them. A failed walk leaves the index untouched and reportsFileIndexer.ProgressStage.FAILED - Progress reporting via
ConsumerofFileIndexer.IndexProgress
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordProgress snapshot during discovery, normalization, and index mutation.static final recordSummary of a completed index run.static enumIndexing lifecycle stage. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an indexer using the shared default admission caps.FileIndexer(com.tnsai.intelligence.rag.binding.FileIngestionService.Limits limits) Creates an indexer with the same admission-cap policy asFileIngestionService. -
Method Summary
Modifier and TypeMethodDescriptionvoidForgets the manifest of previous runs, forcing a full re-index on the next run.index(com.tnsai.rag.KnowledgeSourceConfig source, com.tnsai.knowledge.KnowledgeBase knowledgeBase, BM25Stream bm25Stream, Consumer<FileIndexer.IndexProgress> progressCallback) Indexes one canonical FILE source, including its declared format, selectors, and knowledge-unit slicing policy.index(Path rootDir, com.tnsai.knowledge.KnowledgeBase knowledgeBase, BM25Stream bm25Stream, Consumer<FileIndexer.IndexProgress> progressCallback) Indexes one supported file or all supported files under a directory.
-
Constructor Details
-
FileIndexer
public FileIndexer()Creates an indexer using the shared default admission caps. -
FileIndexer
public FileIndexer(com.tnsai.intelligence.rag.binding.FileIngestionService.Limits limits) Creates an indexer with the same admission-cap policy asFileIngestionService.- Parameters:
limits- max file / depth / corpus policy
-
-
Method Details
-
index
public FileIndexer.IndexResult index(Path rootDir, com.tnsai.knowledge.KnowledgeBase knowledgeBase, BM25Stream bm25Stream, Consumer<FileIndexer.IndexProgress> progressCallback) throws IOException Indexes one supported file or all supported files under a directory. A relativerootDirresolves against the working directory, as aPathdoes, whatever base directoryClassConfig.useBaseDirectory(java.nio.file.Path)set.- Parameters:
rootDir- source file or directory to ingestknowledgeBase- target knowledge baseprogressCallback- receives progress updates (may benull)- Returns:
- result summary
- Throws:
IOException- ifrootDiris not a file or directory
-
index
public FileIndexer.IndexResult index(com.tnsai.rag.KnowledgeSourceConfig source, com.tnsai.knowledge.KnowledgeBase knowledgeBase, BM25Stream bm25Stream, Consumer<FileIndexer.IndexProgress> progressCallback) throws IOException Indexes one canonical FILE source, including its declared format, selectors, and knowledge-unit slicing policy. A relative source path resolves byKnowledgePaths.resolve(java.lang.String): against the base directoryClassConfig.useBaseDirectory(java.nio.file.Path)set, or the working directory when none is set.- Parameters:
source- canonical FILE sourceknowledgeBase- target knowledge basebm25Stream- target BM25 index, ornullprogressCallback- receives progress updates (may benull)- Returns:
- result summary
- Throws:
IOException- if the configured path is not a file or directory- Since:
- 0.15.0
-
clearHashes
public void clearHashes()Forgets the manifest of previous runs, forcing a full re-index on the next run. Waits for a running index to finish so that its commit cannot restore the manifest afterwards.
-