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.
Visual Editor
Manual Editor
- In the Algolia dashboard, select your application and index, open Rules, and select New rule > Visual Editor.
- Click Set query condition(s), select contains, enter
article, and click Apply.
- In Consequences, expand More consequences and select Apply search parameters.
Enter
{ "restrictSearchableAttributes": ["title", "id"] } in Value and click Apply.
- Click Add Consequence, expand More consequences, and select Remove word.
Enter
article in Word(s) and click Apply.
- Preview the results for
article ref21, click Review and Publish, and click Publish.
- In the Algolia dashboard, select Search, select your , and open Rules.
Select Create your first rule or New rule, then select Manual Editor.
- In Condition(s), keep Query selected, select Contains, and enter
article.
- In Consequence(s), click Add consequence and select Add Query Parameter.
Enter
{ "restrictSearchableAttributes": ["title", "id"] }.
- Click Add consequence again and select Remove Word.
Enter
article.
- Save your changes.
Last modified on September 28, 2026