AddSearch automatically generates search suggestions based on searches made on your website. Search suggestions become more relevant over time when the number of searches increases. In addition to suggestions based on user searches, suggestions can also be generated from custom fields or added manually.
The first step is to set up the Search Suggestions in the AddSearch dashboard. Follow the guide here Setting Up Search Suggestions. After setting up the Search Suggestions in the AddSearch dashboard, follow the instructions for different implementation methods below.
You can configure search suggestions using the Search Designer. Open the Search Designer here.
Use the following steps to toggle search suggestions for the Widget view:
Use the following steps to toggle search suggestions for the Separate Results Page view view:
When enabled, the show_search_suggestions: true setting should appear as follows in the exported settings object:
<!-- AddSearch settings --> <script> window.addsearch_settings = { show_search_suggestions: true }; </script> <!-- This script must be below addsearch_settings --> <script src="https://addsearch.com/v5/addsearch-ui.min.js?key=####"></script>
You can implement the Search Suggestions Autocomplete with the Search UI Library autocomplete component. To implement the Search Suggestions Autocomplete, visit the tutorial. Also check out the search suggestions autocomplete example page.
For more information on the Search UI Library visit the Getting Started with Search UI Library article and the Search UI Library reference page.
Please note that implementing the Search Suggestions Autocomplete with the autocomplete component requires familiarity with HTML and JavaScript.
You can also implement Search Suggestions Autocomplete with our REST API. Please note that we recommend using Search API Client for JavaScript with the REST API.
Suggestions for a certain search query can be pulled with a separate API call, for example:
Get request:
https://api.addsearch.com/v1/suggest/1bed1ffde465fddba2a53ad3ce69e6c2?term=api
AddSearch JS library call:
client.suggestions('api', callback);
For reference:
https://www.addsearch.com/support/api-reference/#suggestions
https://www.npmjs.com/package/addsearch-js-client
We’re always happy to help with code or other questions you might have. Search our documentation, contact support, or connect with our sales team.