Console Error: Uncaught Error: Usage: searchBox({

Hi - I’m using JS on page to run instantsearch. It’s working but sporadically.

When it fails, I’m seeing a cryptic console error. Anyone know what this means?

image

This is the CDN I’m using

Hi Whitney,

Could you share the following with us to help troubleshoot with you?

  • The Live page you are receiving this error on
  • Code samples you are using
  • Which specific library you are using

Thanks!
Jason

Thanks for a quick reply. I’m 99% sure it’s related to this hack I implemented.

I have a long string of OR clauses. new values added to our DB are causing it to throw errors.

You can close this thread. I don’t want to suggest this solution to anyone. It’s bad.

I got it working again. If you have any suggestions for how to deal with quotes, I’d appreciate your advice.

The current structure of the query is

filter: ‘field_name:“value 1” OR field_name:“value 2”’

The values are user input. When there are quotes (single or double or parens in the values) my query string is breaking and the algolia search breaks for them.

image
where messages’s algolia groups is a string that can be one or more value all structured as separate OR statements.

Does escaping the user input with something along the lines of this help? Try to escape the quotes in a query on the dashboard and see if it works.