We now have Redis Search in Upstash.If you are starting a new project, we recommend using Redis Search:
- Index and query your Redis data with a schema.
- Use advanced query operators and aggregations.
- Keep your data and search in one place.
Quickstart
Check out our Next.js quickstart guide if you’re working in Next.js.Next.js
Use Upstash Search in your Next.js app
Create a Database
Create a Search Database by navigating to theVector tab and clicking on the Search Database button under Create.
A dialog with the following options will open:
- Name: Type a name for your database (e.g. “product-search”).
- Region: Choose the region for your database. For best performance, select the region closest to your application. We plan to support additional regions and cloud providers. Feel free to send your requests to support@upstash.com.
Next, choose a plan, and your Database is ready:
Add Documents
Add documents to your database using our REST API, our SDKs, or directly in the dashboard.1. Add Documents via Dashboard
Navigate to theData Browser section of your Database and click Upsert Documents:
A dialog with the following options will open:
- Index: An index to group your data. If you plan to query all documents in one place, you only need one index (e.g. “product-search”). If you plan to add multi-tenancy, so that each user can only search their own data, for example, you can create one index per user (“user-1”, “user-2”, etc.).
- ID: An automatically generated ID.
- Content: The searchable data in JSON format.
- Metadata: Optional information attached to this document.
2. Add Documents via SDKs
- Python
- TypeScript
from upstash_search import Search
client = Search(
url="<UPSTASH_SEARCH_REST_URL>",
token="<UPSTASH_SEARCH_REST_TOKEN>",
)
index = client.index("movies")
index.upsert(
documents=[
{
"id": "movie-0",
"content": {
"title": "Star Wars",
"overview": "Sci-fi space opera",
"genre": "sci-fi",
"category": "classic",
},
"metadata": {
"poster": "https://poster.link/starwars.jpg",
},
},
],
)
Search Your Database
You can search across your Database the same way: using our REST API, our SDKs or directly in your dashboard.1. Searching via Dashboard
To search your documents, enter a search term and clickSearch:
2. Searching Data via SDKs
- Python
- TypeScript
scores = index.search( query="space opera", limit=2, )
That’s it! 🎉 You’ve just created your first serverless search database with Upstash Search! But this is just the beginning. Upstash Search also supports:
- Advanced reranking
- Fine-grained control over search results
- Metadata-based filtering
