Upstash Documentation

User Directory

2 min read

This recipe demonstrates building a searchable employee directory with autocomplete, fuzzy name matching, and department filtering.

Schema Design#

The schema uses nested fields for profile data and exact matching for identifiers:

Sample Data#

Waiting for Indexing#

Index updates are batched for performance, so newly added data may not appear in search results immediately. Use SEARCH.WAITINDEXING to ensure all pending updates are processed before querying:

Use $fuzzy with prefix: true for search-as-you-type functionality. This approach handles both incomplete words and typos, providing a more forgiving autocomplete experience:

Handle typos and misspellings in name searches:

Exact Username/Email Lookup#

Find users by exact username or email:

Department and Role Filtering#

Filter users by department, role, or both:

Search by Skills in Bio#

Find users with specific skills or expertise:

Find administrators or users with specific permissions:

Key Takeaways#

  • Use NOTOKENIZE for usernames, emails, and exact-match identifiers
  • Use NOSTEM for proper nouns like names to prevent incorrect stemming
  • Use $fuzzy with prefix: true for search-as-you-type autocomplete with typo tolerance
  • Use $fuzzy to handle typos in name searches
  • Combine nested field paths (e.g., profile.firstName) for structured data