Suggestions (or Ajax search) is a dynamic type of search that allows the user to see and click on results as they are typing. WPSolr allows you to place suggestions in whatever field you want.
Select the “Suggestions” tab
Click on the “2.3 Suggestions” tab on the left.
Select the correct view (if you have PRO edition and up)
Select the view that uses the index of your choice. Each view you created in the WPSOLR view add-on appears in this drop-down list. In this case, I chose the “Elastic” view I created that uses an Elasticsearch index.
Click on “Configure new suggestions”
Clicking on this button will create a new suggestion. You can create as many as you want.
Suggestions options
Each time you click on the “Configure new suggestions” button a new suggestions options section appears. There are a wide range of options to choose from for each suggestions you create. Each one of the sugggestions for this view use the view index (in this case Elasticsearch).
Foreach suggestion, you can click on the “Delete” button to delete it.
Activate this suggestion
Check the “Status” box to make this suggestions active. If you don’t want to use this suggestion, leave this unchecked.
Label
Type in your label. This will appear at the top of this suggestion options section. It is so the administrator can differentiate all the suggestions that appear in this admin page.
CSS selector
Target the search bar that should use this suggestion using the “CSS selector” field. In this case (field of value “input[type=search]”), when the user types in any input of type “search”, Ajax search will be used and suggestions will appear.
Select “Query”
Select the type of query you want to use for this suggestion from the drop-down list. Here are the following options :
- Suggest Keywords : this will return text results based on the user query. When the user selects a keyword result from this Ajax search, a search query using this keyword will be sent to the server.
- Suggest content : this will return all the matching content in bulk.
- Suggest content group by type : this will return all the matching content categorized by type (all matching pages in “Pages” section, all matching products in “Products” section, etc…).
- Questions and answers (only available if using a Weaviate index) : This will return AI generated answers using all the indexed documents based on what the users enter in the search bar.
If you have selected “Suggest keywords”, a new field named “Redirect to” appears.
This will determine the archive that will be used to send the query and return the results. The default archive/search page is “/?s=”. All the keywords you select in the description will be used as a query in this archive.
Choose the template (skin)
Choose the skin you want from a drop-down list.
Maximum number of suggestions
This will set the maximum number of elements that will appear when Ajax search is used.
Filter (for “Suggest content” and “Suggest content group by type” only)
All the content returned will have been filtered by the facets in the archive.
Description
Check the “Description” box to show each one of the results description in the Ajax search.
Image size
Select the image width in this field. If you want each result image to occupy the entire width of the suggestions results section, set it to 100%.
Custom CSS
Enter your own CSS into this field. This enables the admin to easily have total freedom over the suggestions results appearance. To target a specific suggestion, select your own ones class name like the one written above (“.c818E…”).
Order by (for “Suggest content group by type” only)
Select your “Order by” value from the drop-down list :
- Groups with the best suggestion : this will position the groups based on their relevancy (groups containing the most relevant results will appear on top).
- Groups with their position defined below by drag&drop : the admin defines the groups order manually in the suggestions.
Select content types to display
This “Show” section is drag & drop. All the data that appears here are the ones you selected in “2.2 Data” and you can reposition them however you want.
For Woocommerce products, you can select the data to display (rating, price, add to cart).
Save suggestions
Click on the “Save suggestions” button at the bottom of the page to save all the different suggestions configurations you created.