Stopwords

Stopwords are common words (like “the”, “and”, “is”) that are excluded from search queries to improve relevance. Define per-locale stopword sets and apply them selectively to queries.

Create a Stopword Set

PUT /stopwords/english_stopwords
Content-Type: application/json
X-TYPESENSE-API-KEY: YOUR_API_KEY

{
  "stopwords": ["the", "a", "an", "and", "or", "but", "in", "on", "at", "to", "for", "of", "is", "it"],
  "locale": "en"
}

Parameters

FieldTypeDescription
stopwordsstring[]Array of words to exclude from search queries.
localestringLanguage code for this stopword set (e.g., en, sv).

Using Stopwords in Search

Specify which stopword set to apply with the stopwords parameter:

GET /collections/products/documents/search?\
q=the best running shoes&query_by=title&stopwords=english_stopwords
X-TYPESENSE-API-KEY: YOUR_API_KEY

With the stopword set above, the query “the best running shoes” would be processed as “best running shoes” since “the” is a stopword.

Note: Stopwords are applied at query time only, not during indexing. All words are still indexed — stopwords simply prevent common terms from being included in the search.

List Stopword Sets

GET /stopwords
X-TYPESENSE-API-KEY: YOUR_API_KEY

Get a Stopword Set

GET /stopwords/english_stopwords
X-TYPESENSE-API-KEY: YOUR_API_KEY

Delete a Stopword Set

DELETE /stopwords/english_stopwords
X-TYPESENSE-API-KEY: YOUR_API_KEY

Persistence

Stopword sets are persisted to disk and restored on server restart.