Skip to main content
Optional filters are a powerful tool for influencing the ranking of search results. Use them to boost or bury records based on specific criteria, but without hiding those records. For example, on a website that handles fast food deliveries, if a user types “hungry” and clicks the “deliver quickly” option, the website will show the restaurants that can deliver the fastest at the top of the list but still show other restaurants. You can also use negative optional filters to demote records. For example, to lower the ranking of restaurants with poor reviews.
This feature isn’t available on every plan. Refer to your pricing plan to see if it’s included.

Update your records

Since optional filters only work with exact matches, you might need to update your records. Using the fast food delivery website as an example, flag restaurants that can deliver within 20 minutes by adding a boolean attribute called can_deliver_quickly and set it to true or false for each record.
JSON

How to apply optional filters

To use optional filters, you need to:
  • Set the attribute in attributesForFaceting at indexing time. You can do this either through the API or the Algolia dashboard.
  • Add the optional filter through a rule or send it with your query using the API.

Using the dashboard

Set the attribute to use for faceting in your Algolia dashboard:
  1. Go to the Algolia dashboard and select your Algolia .
  2. On the left sidebar, select Search.
  3. Select your Algolia index and go to the Configuration tab.
  4. Under Filtering and Faceting > Facets, click Add an attribute and select the optional filter attributes (for example, can_deliver_quickly).
  5. Save your changes.
You can create a rule to boost records where can_deliver_quickly is true using either the Visual Editor or the Manual Editor.
  1. Open Rules and select New rule > Visual Editor.
  2. In Conditions, select Create conditionless rule and click Apply to apply the boost to every search. To limit the boost to specific queries, select Set query condition(s) instead.
  3. In Consequences, select Boost categories. Select can_deliver_quickly as the attribute and true as its value, then click Apply.
  4. Preview the results with an empty query, click Review and Publish, and click Publish.
Using the example dataset, the rule boosts records where can_deliver_quickly is true, while the other record remains in the results. To demote records instead, use Bury categories in the Visual Editor. For example, select can_deliver_quickly as the attribute and false as its value. In the Manual Editor, use Add Query Parameter with { "optionalFilters": ["can_deliver_quickly:-false"] } for the same effect.

Using the API

To run the code examples on this page, install the latest API client. Set the attribute to use for faceting with attributesForFaceting. For example:
Send the optional filters with your query. For example:
You can also add negative optional filters. For example, to demote a specific restaurant:

Optional or facet filters

Whether to use optional filters or facet filters depends on your goals:
  • Use optional filters to boost records.
  • Use facet filters if you need to filter out records.

See also

Last modified on September 28, 2026