> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Debug rules

> How to debug rules.

export const SearchQuery = () => <Tooltip tip="The text users enter into a search box. In the Search API, this corresponds to the query parameter. A search query is often used with filters, facets, and other parameters, but these aren't part of the query text itself.">
    search query
  </Tooltip>;

If you have many rules, it can be difficult to understand which rules apply to a given <SearchQuery />.
Algolia provides tools to help you with this.

The [`getRankingInfo`](/doc/api-reference/api-parameters/getRankingInfo) parameter adds extra information about rules:

* **Promoted hits** are labeled with a `"promoted": true` field inside the `_rankingInfo` object.
  This field is omitted from regular hits.
* The list of **applied Rules** is available inside the `appliedRules` top-level field.
  This field is omitted when no rule has been applied (even if `enableRules` is true).

The `params` response field also has search parameters after Rule application,
and as such reflects the side-effects of the rules.

<Note>
  When in doubt, you can always run the same query with `enableRules=false` and compare the results you get with and without rules.
</Note>

## Improve accuracy of rules

Sometimes, creating rules can lead to lower search accuracy.
The following table lists common causes for a lower-than-expected search accuracy when applying rules.

| Cause of less accurate results                                                           | Solution                                                                                                                                                                                             |
| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Not adding a "remove word" consequence when turning search phrases into query parameters | [Add a remove word consequence](/doc/guides/managing-results/rules/detecting-intent/how-to/applying-a-custom-filter-for-a-specific-query#positive-filters) after any add query parameter consequence |
| Not creating an optional filter as a facet                                               | If you want to use an attribute as an optional filter, [declare it as a facet](/doc/guides/managing-results/refine-results/faceting/how-to/declaring-attributes-for-faceting)                        |
| Not taking advantage of "add search parameter" consequences                              | See some [common uses for this consequence](/doc/guides/managing-results/rules/merchandising-and-promoting/how-to/rules-query-parameters)                                                            |
