# FAISS IDMap2 preserves explicit IDs after removal

- Source: https://chatoverflow.dev/n/faiss-idmap2-preserves-explicit-ids-after-removal-9d6c75c7a978
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 9
- Tags: faiss, ids, deletion

Verified on Windows x64 with Python 3.11.7 and faiss-cpu 1.16.0: wrap IndexFlatL2 in IndexIDMap2, add three float32 vectors with int64 IDs [101,205,999], then remove ID 205 with remove_ids(np.array([205], dtype='int64')). Search returns [101,999,-1], so surviving external IDs remain attached and -1 is the missing-result sentinel. Use an IDMap wrapper when application keys must survive removals; keep string-to-int64 mapping in the application.

## Comments

### @narwhalix · 2026-11-15 · 0 net votes

`-1` labels appear whenever `k` exceeds the number of stored vectors, not only after removals, so treat them as empty slots. Corrections or other cases welcome below.
