Skip to content

You are viewing docs for an old version. Switch to latest v30.2.

Curation ​

While Typesense makes it really easy and intuitive to deliver great search results, sometimes you might want to promote certain documents over others. Or, you might want to exclude certain documents from a query's result set.

Using overrides, you can include or exclude specific documents for a given query.

Create or update an override ​

Including or excluding documents ​

In the following example, we will:

  1. Use the includes condition to place the documents with ids 422 and 54 in the first and second positions respectively.
  2. Use the excludes condition to remove the document with id 287 from the results.

Typesense allows you to use both includes and excludes or just one of them for curation.

Note how we are applying these overrides to an exact match of the query apple. Instead, if we want to match all queries containing the word apple, we will use the contains match instead.

Sample Response ​

Dynamic filtering ​

In the following example, we will apply a filter dynamically to a query that matches a rule.

With this override in effect, any query that contains a brand will automatically be filtered on the matching brand directly. In addition, the brand will also be removed from the original query tokens, so that the search is made only on the remaining tokens.

For example, if someone searches for sony ericsson phone, the query will be re-written as phone and a sony ericsson brand filter will be directly applied. If you don't wish to remove matching tokens from the query, set remove_matched_tokens to false. By default, this parameter is set to true.

Definition ​

PUT ${TYPESENSE_HOST}/collections/:collection/overrides/:id

Parameters ​

ParameterRequiredDescription
rule.queryyesIndicates what search queries should be overridden.
rule.matchyesIndicates whether the match on the query term should be exact or contains.
excludesnoList of document ids that should be excluded from the search results.
includesnoList of document ids that should be included in the search results with their corresponding positions.
filter_bynoA filter by clause that is applied to any search query that matches the override rule.
remove_matched_tokensnoIndicates whether search query tokens that exist in the override's rule should be removed from the search query.

Default: true.

List all overrides ​

Listing all overrides associated with a given collection.

Sample Response ​

Definition ​

GET ${TYPESENSE_HOST}/collections/:collection/overrides

Retrieve an override ​

Fetch an individual override associated with a collection.

Sample Response ​

Definition ​

GET ${TYPESENSE_HOST}/collections/:collection/overrides/:id

Delete an override ​

Deleting an override associated with a collection.

Sample Response ​

Definition ​

DELETE ${TYPESENSE_HOST}/collections/:collection/overrides/:id

You are viewing docs for an old version. Switch to latest v30.2.