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:

  1. 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.
  2. 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.
  3. 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.
  4. Display type: This field indicates the type of the display content used by the display content field.
  5. Category group: This field can contain a string that is used to group the suggestions.
  6. Category type: This field is currently unused and is left blank.
  7. 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.
  8. 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

  1. Load the Funnelback administration interface and select the the collection (search interface) you would like to add query completion suggestions.&
  2. Open the file manager.
    1. Select Administer tab > Browse Collection Configuration Files
  3. Create a new query_completion.csv file.
    1. 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.
  4. Add your auto-completion suggestions.
    1. 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.
  5. 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

  1. Set your query_completion.csv as auto-completions suggestions source.
    1. Go back to Home, then Select Administer tab > Edit Collection Settings.      
    2. Go to Query Completion section in side bar.
    3. For Query Completion Source select the option Collection CSV file (query_completion.csv).
    4. 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.
    5. Save.
  2. Re-index collection to generate the auto-completion suggestions.
    1. Go back to Update tab > Start Advanced update then select Reindex live view and click update.

3. View Custom Suggestions

  1. 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?

Tags
Type:
Features: Frontend > Auto-completion