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

# Detect intent

> Use Rules to detect user intent by looking at the keywords they use in their queries.

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>;

export const Records = () => <Tooltip tip="A record is a searchable object in an Algolia index. Each record consists of named attributes." cta="Algolia records" href="/doc/guides/sending-and-managing-data/prepare-your-data#algolia-records">
    records
  </Tooltip>;

export const Index = () => <Tooltip tip="An Algolia index is a searchable dataset that consists of records and configuration settings. These settings define how the records are searched and ranked.">
    index
  </Tooltip>;

**Keywords** in a <SearchQuery /> are crucial terms that show user intent.
They vary depending on the data in your <Index />.
For example, if a user types "red":

* On a clothing site, they're probably looking for red clothes.
* On a movie site, "red" might not refer to color.

Once you understand what specific keywords mean in queries,
[use rules to adjust the search results](/doc/guides/managing-results/rules/rules-overview#rules-responding-to-user-queries) users get when they use those keywords.
For example, you can:

* Dynamically filter
* Change the entire query
* Category searches
* Dynamically change search parameters.

## Dynamically filter based on the query

Dynamic filtering applies filters based on keywords.
For example, if someone searches for "cheap toaster 800w",
you could create a rule to filter on toasters priced under \$25 with an 800w power rating.

For more information, see:

* [Add filters based on the query](/doc/guides/managing-results/rules/detecting-intent/how-to/applying-a-custom-filter-for-a-specific-query)
* [Dynamic filtering with Rules](/doc/guides/managing-results/rules/detecting-intent/how-to/applying-a-filter-if-the-query-match-a-facet-value)
* [Merchandising](/doc/guides/managing-results/rules/merchandising-and-promoting)

## Change the entire query

Sometimes, users may search using informal terms not in your <Records />.
For example, "iwatch" instead of "apple watch".

To handle this, you can create rules to replace an entire query with an alternative set of words.

For example, to replace queries containing "iwatch" with an "apple watch" query:

```json JSON icon=braces theme={"system"}
{
  "conditions": [
    {
      "anchoring": "is",
      "pattern": "iwatch",
      "alternatives": false
    }
  ],
  "consequence": {
    "params": {
      "query": "apple watch"
    }
  }
}
```

To help determine these informal terms, review your [Search analytics](/doc/guides/search-analytics/overview).

## Category searches

You can use rules to recognize [categories](/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/tutorial/generate-sitemap-from-index#create-a-sitemap-for-categories) in queries and refine the results based on that.
For example, on a document library site, in the query "article ref21," "article" is a category.

* Without a rule, the search probably fails since it searches for the terms "article" and "ref21" but it's unlikely that your records contain the category name "article".
* With a rule that [recognizes and removes](/doc/guides/managing-results/rules/detecting-intent/how-to/detecting-keywords) the "article" category, the search succeeds ("ref21" replaces "article ref21").

## Dynamically change search parameters

After parsing a query, you can use a rule to determine which [parameters best apply to the search](/doc/guides/managing-results/rules/detecting-intent/how-to/applying-search-parameters-for-a-specific-query).

For example, you can turn typo tolerance on or off, change geolocation settings, search for only certain types of attributes, or add filters.
