Generate custom auto-completion suggestions
Managed by | Updated .
Prerequisites
- Collection has been crawled with auto-completion data configured.
- Auto completion has been added to your search input see Add auto-completion to your search.
- Understanding of the CSV (Comma Separated Values) syntax format.
Objective
Add custom suggestions to the the Funnelback Auto-completion.
Understanding the Query Completion CSV
The query_completion.csv is used for defining custom suggestions for auto-completion.
The CSV file can be edited directly from within Funnelback, or uploaded via the file manager.
The CSV file format used by auto-completion is detailed in the Funnelback documentation - Auto-completion CSV data.
The CSV file contains 8 columns:
- Trigger: This is the word, or set of words that will trigger the suggestion to display.The keywords that are input by the user are left matched against this trigger.
- Weight: This is the weighting to apply to the suggestion Range is 0 – 999. This weight is used to determine the order that suggestions will display when default sorted. Choose a high value (eg. 900) as your starting point and work from there. For most applications having same weight 900 for all the rich suggestions works well.
- Display content: This is what is displayed to the user – it can be plain text (like for the organic suggestions, a html fragment (as nested within a DIV), a JavaScript statement to execute or JSON data.
- Display type: This field indicates the type of the display content used by the display content field.
- Category group: This field can contain a string that is used to group the suggestions.
- Category type: This field is currently unused and is left blank.
- Action: This field contains either a keyword string, a URL or a JavaScript callback function. A keyword string will be run as a search (as though the user input the string into the search box, a URL will take a user directly to the URL and the JavaScript callback will be executed.
- Action type: This field indicates the type of action above. U (for URLs) is the most common choice for rich auto-completion.
Steps
1. Create Suggestions
- Load the Funnelback administration interface and select the the collection (search interface) you would like to add query completion suggestions.&
- Open the file manager.
- Select Administer tab > Browse Collection Configuration Files
- Create a new query_completion.csv file.
- Select query_compeltion.csv in the file creater drop down and select create. This action will create the query_completion.csv and open it file ready for editing.
- Add your auto-completion suggestions.
- Paste the following into the editor window and then save the file.
This creates 5 custom suggestions, showcase the different ways to customise a Auto-completion suggestion.
- Paste the following into the editor window and then save the file.
Completion HTML,90,"<div>This <strong>actually is HTML</strong></div><strong>",H,Display samples,1,v:html,Q
Completion Text,70,This is plain text,T,Display samples,1,plain text,Q
Completion Callback,1,'Callback. Current document title is: <em>'+document.title+'.</em>';,C,Display samples,1,Javascript,Q
Action Query,90,This will run a query,T,Action samples,1,`a query`,Q
Action URL,80,This will open an URL (http://funnelback.com/),T,Action samples,1,http://funnelback.com/,U
2. Generate Suggestions
- Set your query_completion.csv as auto-completions suggestions source.
- Go back to
Home, then Select Administer tab > Edit Collection Settings. - Go to Query Completion section in side bar.
- For Query Completion Source select the option Collection CSV file (query_completion.csv).
- For Query completion Program options append the text label_organics>
This option enables the display of the category title for organic suggestions so that we can distinguish them from the structured suggestions see Build autocompletion options. - Save.
- Go back to
- Re-index collection to generate the auto-completion suggestions.
- Go back to Update tab > Start Advanced update then select Reindex live view and click update.
3. View Custom Suggestions
- View the search results page and perform a search for Completion and Action observing the suggestions displayed.
Working Example
See functional example on code pen.
Was this artcle helpful?