How do you update or delete a RedisSearch index without affecting the underlying data it was built from?
Short answer
You use FT.DROPINDEX to remove an index definition, with the option to also delete the underlying documents if desired or leave them intact if you plan to recreate the index later, and to change an index's schema you typically need to drop and recreate it with the new field…
Advertisement
AModel answer
You use FT.DROPINDEX to remove an index definition, with the option to also delete the underlying documents if desired or leave them intact if you plan to recreate the index later, and to change an index's schema you typically need to drop and recreate it with the new field definitions, since RedisSearch does not support modifying an existing field's type directly.
Example
FT.DROPINDEX product_idx FT.CREATE product_idx ON HASH PREFIX 1 product: SCHEMA name TEXT price NUMERIC brand TAG
Real-world example
A team needing to add a new searchable field to their product index drops the existing index definition and recreates it with the updated schema, while their actual underlying product data in Redis remains completely untouched throughout the process.
Likely follow-ups
- Does dropping an index affect the actual underlying data by default?
- How long does it take to rebuild an index for a very large dataset?
Related topics