@upstash/search is a TypeScript SDK for Upstash AI Search.
Using @upstash/search you can:
- Perform AI-powered search queries
- Upsert documents to an index
- Fetch documents by their IDs
- Delete documents from a database
- Access database stats
- Reset databases
Installation
Usage
Initializing the client
There are two pieces of configuration required to use the Upstash search client:- a REST token
- a REST URL
Using environment variables (recommended)
You can follow this guide to retrieve the following credentials.Using a configuration object
TheSearch class accepts a config object containing the url and token values. This
could be useful if your application needs to interact with multiple databases, each with a different configuration.
Typescript
The Search SDK supports defining your content and metadata types at the index level for complete type-safety.Content type at the index level will provide type safety for the content coming back from or required for the following commands:
searchupsertfetchrange
Telemetry
This sdk sends anonymous telemetry data to help us improve your experience. We collect the following:- SDK version
- Platform (Cloudflare, AWS or Vercel)
- Runtime version (node@18.x)
UPSTASH_DISABLE_TELEMETRY environment variable
to any truthy value.