Skip to main content
DocSearch uses Algolia’s powerful search API. You can configure search parameters to control filtering, ranking, attributes, and more.

Configuring Search Parameters

Search parameters can be set at two levels:
  1. Per-index (recommended) - using the indices prop
  2. Global (deprecated) - using the top-level searchParameters prop

Per-Index Configuration

Using per-index searchParameters allows different configuration for each index when searching multiple indices.

Common Search Parameters

Filtering

facetFilters

Filter results by facet values. Supports AND/OR logic:
Common use cases:
  • Version filtering: facetFilters: ['version:latest']
  • Language filtering: facetFilters: ['language:en']
  • Category filtering: facetFilters: ['category:tutorial']

filters

Use filter expressions for more complex logic:
Operators:
  • Comparison: =, !=, <, <=, >, >=
  • Logic: AND, OR, NOT
  • Grouping: ()

Attributes

attributesToRetrieve

Specify which attributes to retrieve (improves performance):
By default, DocSearch retrieves hierarchy.lvl0 through hierarchy.lvl6, content, type, and url. Only override if you need to optimize performance or exclude certain attributes.

attributesToSnippet

Control snippet length for each attribute:

restrictSearchableAttributes

Limit which attributes are searched:

Pagination and Limits

hitsPerPage

Number of results per query:
For DocSearch, combine hitsPerPage with the maxResultsPerGroup prop to control result display.

Highlighting and Snippeting

highlightPreTag / highlightPostTag

Customize highlight markup:
Default values:
  • highlightPreTag: '<mark>'
  • highlightPostTag: '</mark>'

snippetEllipsisText

Customize ellipsis text:

Advanced Parameters

distinct

Remove duplicate or similar results:

clickAnalytics

Enable click analytics:
When the top-level insights prop is true, clickAnalytics is automatically enabled unless explicitly set to false in searchParameters.

optionalWords

Make certain query words optional:

removeWordsIfNoResults

Automatically remove words if no results found:

Complete SearchParamsObject Type

Here’s the TypeScript interface from algoliasearch:
SearchParamsObject includes:
  • query?: string
  • facetFilters?: string[] | string[][]
  • filters?: string
  • attributesToRetrieve?: string[]
  • attributesToSnippet?: string[]
  • restrictSearchableAttributes?: string[]
  • hitsPerPage?: number
  • highlightPreTag?: string
  • highlightPostTag?: string
  • snippetEllipsisText?: string
  • distinct?: boolean | number
  • clickAnalytics?: boolean
  • And many more…

Full API Reference

See the Algolia API documentation for all available search parameters.

Common Patterns

Version-Specific Documentation

Search with Ask AI Parameters

When using Ask AI, you can also configure search parameters for the AI context:
Ask AI searchParameters are separate from index searchParameters. They control what content the AI uses to generate answers.

Debugging Search Parameters

Viewing Search Requests

Use transformSearchClient to log search requests:

Testing Parameters

Test parameters in Algolia dashboard before adding them to your code:
  1. Go to your Algolia dashboard
  2. Open the “Search” page
  3. Use the search parameters panel to test filters, facets, etc.
  4. Once satisfied, copy the parameters to your code

Migration from Deprecated Props

The top-level searchParameters prop is deprecated. Use per-index parameters with the indices prop instead.

Before (Deprecated)

Complete Example