Skip to main content
You can use rules to detect a specific word and modify a parameter because of this word.

Limit the search to only a subset of attributes

A good example of altering a query is with an online document library that allows keyword searches inside documents. If a user types in the word “article ref21”, they’re probably looking for an article whose title or ID contains “ref21”._

Rule

If query = “article ref21” then remove article and search for an article whose title or ID contains ‘ref21’

Using the API

To run the code examples on this page, install the latest API client.

Using the dashboard

You can add this rule from the Algolia dashboard using either the Visual Editor or the Manual Editor. The title and id attributes must already be in your index’s searchableAttributes.
  1. In the Algolia dashboard, select your application and index, open Rules, and select New rule > Visual Editor.
  2. Click Set query condition(s), select contains, enter article, and click Apply.
  3. In Consequences, expand More consequences and select Apply search parameters. Enter { "restrictSearchableAttributes": ["title", "id"] } in Value and click Apply.
  4. Click Add Consequence, expand More consequences, and select Remove word. Enter article in Word(s) and click Apply.
  5. Preview the results for article ref21, click Review and Publish, and click Publish.
Last modified on September 28, 2026