Wordpress Search specific index


I have Algolia search installed on WordPress.

I have multiple search forms on the site, one for general search (which searches everything) and one for searching team members (which also searches everything)

On the autocomplete dropdown for team members, how can I only search the specific index for team members and not everything?

1 Like

Het @beng,

This is unfortunately not possible by default. The autocomplete dropdown will attach itself to every input named “s”.

Maybe there is a trick with autocomplete.js to remove existing datasource of an already loaded autocomplete, but I’m not sure that will be easy to do.

What you can do is add a “.no-autocomplete” class to the members input so that autocomplete doesn’t get loaded there. see: https://github.com/algolia/algoliasearch-wordpress/blob/e35bdc6f3ca8b106fb68e99b16d696420f7e9a4f/includes/class-algolia-template-loader.php#L43

Then you’ll have to manually load the autocomplete by inspiring from: https://github.com/algolia/algoliasearch-wordpress/blob/master/templates/autocomplete.php

I hope that helps,

1 Like

This is great! It will allow the autocomplete/instantsearch of algolia on individual indexes, really useful indeed.

Do you guys foresee adding this customisation to future releases of the plugin?

Hi Beng,

Just wondering if you committed time to the proposed solution and could made it work :slight_smile: