Don't search till after third keystroke

Hey there,

I love algolia but on a high traffic site they search is killing our pocket. Is it possible to delay the instant search to not activate till after the 3rd keystroke?

Hi there. We have a custom text input (using connectSearchBox) which we use to a) debounce the search and b) prevent searching if there are less than 3 characters. Pseudo-code:

import debounce from 'lodash/debounce'
import { connectSearchBox } from 'react-instantsearch-dom'

function SearchInput(props) {
  const { refine, currentRefinement } = props // Provided by connector

  const debouncedRefine = debounce(refine, 300)

  function onChange(event)  {
    const query = event.target.value
    debouncedRefine(query)
  }
}

export default connectSearchBox(SearchInput)

Note: we’re still on V5 of React InstantSearch.

HTH,
Rob

You could also look at this : Conditional requests with React InstantSearch | Algolia