Skip to main content
You stop selling a product, but you keep it in your index: order history, direct links, and your analytics still need it. It should simply disappear from search. The same need comes up with archived help articles, or with a document you must take down immediately after a complaint. Hiding solves this in one rule, and takes effect without reindexing your documents.

Set up from the Meilisearch Cloud dashboard

Open your project in the Meilisearch Cloud dashboard, select the Search rules tab, and click New rule. Give the rule an ID, such as hide-discontinued, and a description. In the Actions block, click Add action, select Hide documents, then click Next. Pick Use a filter to hide a whole set of documents at once, or Pick documents by hand for a short list, then fill in the dialog:
  • Index: the index holding the documents, here products.
  • Filter: the condition selecting them, here discontinued = true. The attribute you filter on must be in the filterableAttributes setting of the index, otherwise the action selects no document.
The dialog tells you how many documents disappear from the results. Click Add action. Hide documents dialog with the index and the filter Leave the Conditions block with its default values, so the rule applies to every search, then click Create rule. Meilisearch indexes the rule, which can take a few seconds to a few minutes. Once it is live, the discontinued products no longer appear in any search, and nothing was removed from your index. To bring them back, pause the rule or delete it.

Set up on a self-hosted instance

Search rules must be turned on before you call the /dynamic-search-rules routes, otherwise Meilisearch returns an error. See Create your first rule.
  • Hiding is a scale action with a weight of 0.
  • Hidden documents leave the results and the facet counts, but they stay in your index. You can still retrieve them with the documents endpoints.
  • If another rule pins a hidden document, the document is pinned. See specific behaviors.
  • The attributes used in filter must be in the filterableAttributes setting of the index, otherwise the action selects nothing.
Meilisearch answers with a summarized task containing a taskUid, because creating a rule is an asynchronous operation:
The rule applies to searches once this task reaches the succeeded status. To follow its progress, pass the taskUid to the task API. From then on, the discontinued products disappear from the results and from the facet counts, for every search and every user, while they stay in your index.

Next steps

Deboost documents

Lower documents instead of removing them

Boost documents

Rank a selection of documents higher

Pause a rule

Bring the hidden documents back

API reference

Endpoints, rule fields, and update behavior