For JSON, hash, and string indexes, documents are regular Redis keys. For a stream index, each stream entry is a separate document.
Keys matching an index prefix and entries in an indexed stream are indexed automatically. When the indexed data changes, the index is updated automatically.
There is no separate update command for search. Use regular Redis write commands to change your data.
Any command that modifies indexed document data updates the index. For example, this includes commands such as:
- JSON commands such as
JSON.SET,JSON.MERGE, ... - Hash commands such as
HSET,HINCRBY, ... - String commands such as
SET,SETEX, ... - Stream commands such as
XADD,XDEL,XTRIM, ... - Generic commands such as
DEL,EXPIRE,PEXPIRE, ...
This is not an exhaustive list. The rule is that if a command changes data represented by an indexed document, the index is updated.
Index updates are batched for performance, so recent writes may not immediately appear in search results.
Use SEARCH.WAITINDEXING when you need to ensure queries reflect recent changes.
JSON Documents#
For JSON indexes, any JSON command that modifies a matching key updates the indexed document.
Hash Documents#
For hash indexes, any hash command that modifies a matching key updates the indexed document.
String Documents#
For string indexes, indexed keys must contain valid JSON strings. Any command that replaces or modifies the matching string key updates the indexed document.
Stream Entries#
For a stream index, XADD adds one document whose ID is the stream entry ID. Commands that remove
entries, including XDEL and XTRIM, remove the corresponding documents from the index.
Deleting or expiring the entire stream clears its documents but keeps the index definition. New entries are indexed if the stream is later recreated under the same key.
See Searching Streams for stream-specific schema rules and operational constraints.
Deletes#
Deleting a matching key removes the document from a JSON, hash, or string index. Deleting a stream removes all of that stream's entry documents from its stream index.
Expiration#
When a matching key expires, Upstash Redis Search removes the expired document from the index.
Eviction#
When an indexed key is evicted, Upstash Redis Search removes the document from the index. Once the Redis key is gone, it no longer appears in search results.