Skip to main content
Configures search parameters to apply when the widget mounts. This is a renderless widget that allows you to set any Algolia search parameter.

Usage

import instantsearch from 'instantsearch.js';
import { configure } from 'instantsearch.js/es/widgets';

const search = instantsearch({
  indexName: 'instant_search',
  searchClient
});

search.addWidgets([
  configure({
    hitsPerPage: 20,
    distinct: true
  })
]);

search.start();

Parameters

The configure widget accepts any valid Algolia search parameter.
hitsPerPage
number
Number of hits per page.
distinct
boolean | number
Enable or disable the distinct feature. Can be a boolean or an integer.
filters
string
Filter hits by facet value.
facetingAfterDistinct
boolean
Force faceting to be applied after deduplication.
attributesToSnippet
string[]
List of attributes to snippet, with an optional maximum number of words to snippet.
snippetEllipsisText
string
String used as an ellipsis indicator when a snippet is truncated.
restrictSearchableAttributes
string[]
Restrict which attributes can be searched.
typoTolerance
boolean | string
Enable or disable typo tolerance.
minWordSizefor1Typo
number
Minimum number of characters a word must contain to allow one typo.
minWordSizefor2Typos
number
Minimum number of characters a word must contain to allow two typos.
allowTyposOnNumericTokens
boolean
Whether to allow typos on numeric tokens.
ignorePlurals
boolean | string[]
Remove plurals from queries.
disableTypoToleranceOnAttributes
string[]
Disable typo tolerance on specific attributes.
queryType
string
Controls how the query is interpreted (prefixAll, prefixLast, prefixNone).
removeWordsIfNoResults
string
Strategy to remove words from the query when no results are found.
advancedSyntax
boolean
Enable advanced query syntax.
optionalWords
string | string[]
List of words that should be considered optional when found in the query.
removeStopWords
boolean | string[]
Remove stop words from the query.
exactOnSingleWordQuery
string
Controls how exact matches are ranked.
alternativesAsExact
string[]
List of alternatives that should be considered as exact.

Examples

Basic configuration

configure({
  hitsPerPage: 20,
  distinct: true,
  attributesToSnippet: ['description:50']
});

Advanced filtering

configure({
  filters: 'price < 100 AND categories:Electronics',
  facetingAfterDistinct: true
});

Typo tolerance settings

configure({
  typoTolerance: 'strict',
  minWordSizefor1Typo: 4,
  minWordSizefor2Typos: 8,
  disableTypoToleranceOnAttributes: ['brand', 'sku']
});

Query behavior

configure({
  queryType: 'prefixLast',
  removeWordsIfNoResults: 'allOptional',
  advancedSyntax: true,
  optionalWords: ['the', 'a', 'of']
});

Notes

  • This is a renderless widget that doesn’t display any UI.
  • Multiple configure widgets can be used, but parameters from the last one take precedence.
  • All search parameters are forwarded to the Algolia search.
  • Parameters are only active while the widget is mounted.

Build docs developers (and LLMs) love