Compact Index
Sweep the dead vectors out of your FAISS index
- index
- index
- status
Every time you remove a folder or a file from a semantic index, the database record goes away but the vector stays - FAISS flat, IVF, and HNSW indexes don't support true deletion. Those orphaned vectors don't show up in search results, but they keep eating disk and memory. Compact Index is the housekeeping node that rebuilds the FAISS file with only the live vectors, reclaiming the space.
The mechanism is exactly "rebuild without the gaps": it reads the index, checks how many deleted vectors are lurking, and if there's anything to clean it rebuilds the index keeping only active entries. The node's own status string reports the before/after counts - something like Compacted index: 12847 → 11000 vectors (removed 1847 orphaned) - so you can see exactly what it did. If there's nothing to compact it just says so and returns the index untouched.
Two practical points. First, this isn't something you run every session - the pack's guidance is to compact when wasted space exceeds ~10%, and Get Index Info is the node that tells you the current waste percentage and literally flags "⚠️ Compaction recommended!". Second, compaction is the cheap way to change index type: the optional new_index_type dropdown (Keep Current, Flat (Exact), IVF-Flat (Fast), HNSW (Very Fast)) lets you convert a Flat index to HNSW at the same time as cleaning it. That's the pack's sanctioned upgrade path - you don't have to rebuild and re-embed your whole library to switch to a faster index.
Inputs and outputs
Required: index. Optional: new_index_type (default Keep Current). Outputs: the same SEMANTIC_INDEX plus a status STRING. It's non-destructive to your files and images - it only rewrites the vector store.
Install
Standard pack install: ComfyUI Manager (search "Semantic-Search") or git clone https://github.com/EricRollei/Semantic-Search into custom_nodes, pip install the requirements (faiss-cpu, qwen-vl-utils, Pillow, numpy), restart, nodes under Eric/SemanticSearch.
Where people get burned
- Nothing happens and you expected something.
No compaction needed - no deleted vectorsis the node working correctly. If you haven't removed anything, there's nothing to clean. If you have removed things and it still says nothing to do, the removals may have used a path that didn't match (see Remove Folder from Index). - Compacting doesn't speed up Flat search. Compaction reclaims space; it doesn't change search speed for a Flat index. If you're compacting to fix slow search, that's the wrong tool - that's what converting to IVF or HNSW via
new_index_typeis for. - Large indexes take a while. Rebuilding a multi-GB FAISS file isn't instant, and it does hold the index in memory during the rebuild. On a big library, expect a visible pause and let it finish - interrupting mid-rebuild is the one way to actually break an index file.
Compact Index is the "vacuum" of this pack: unglamorous, occasionally critical, and you'll be glad you ran it before your index ballooned to twice the size of the photos it represents.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| index | SEMANTIC_INDEX | — | |
| new_index_typeopt | COMBO | Keep Current | Optionally change index type during compaction. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| index | SEMANTIC_INDEX | — |
| status | STRING | — |