Configuring Search Parameters
Search parameters can be set at two levels:- Per-index (recommended) - using the
indicesprop - Global (deprecated) - using the top-level
searchParametersprop
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:- Version filtering:
facetFilters: ['version:latest'] - Language filtering:
facetFilters: ['language:en'] - Category filtering:
facetFilters: ['category:tutorial']
filters
Use filter expressions for more complex logic:- 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: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?: stringfacetFilters?: string[] | string[][]filters?: stringattributesToRetrieve?: string[]attributesToSnippet?: string[]restrictSearchableAttributes?: string[]hitsPerPage?: numberhighlightPreTag?: stringhighlightPostTag?: stringsnippetEllipsisText?: stringdistinct?: boolean | numberclickAnalytics?: boolean- And many more…
Full API Reference
See the Algolia API documentation for all available search parameters.
Common Patterns
Version-Specific Documentation
Multi-Language Search
Filtered Category Search
Performance-Optimized Search
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
UsetransformSearchClient to log search requests:
Testing Parameters
Test parameters in Algolia dashboard before adding them to your code:- Go to your Algolia dashboard
- Open the “Search” page
- Use the search parameters panel to test filters, facets, etc.
- Once satisfied, copy the parameters to your code
