UpStart Commerce Search
Suggest (Type Ahead)
4min
suggest is a unique feature of nochannel search that allows users to complete their queries faster and as soon as they start typing the users can funnel their search quickly and require minimum input from the user to further facilitate the person making the query, type ahead highlights the portion of the result that matches the initial query suggest also gives the users the ability to jump to a results page directly i e the product page of the suggest for example, if users type the query "mat" the results will show "match box", "mattress", "door mat", and other similar words the portions with "mat" will be highlighted to understand the concept of suggestion better, consider the example discussed below note suggestion request is first transformed into opensearch request and then it is sent to the index for the searching process using typeahead in route the api call for type ahead in route is post https //api upstartcommerce com/v1/search/routes/route id/suggest notice that the end of the url "suggest" is explicitly mentioned suggest uses the authorization of route this means that if the authorization of a route is set to public, then the suggest will also be public the following code block represents the suggest endpoint { "suggest" { "prefix" "pho", "query" { "bool" { "must" \[ { "bool" { "should" \[ { "term" { "typename keyword" "phone protector" } } ] } } ] } }, "suggest fields" \[ "name" ], "suggest options" { "matchasphrase" false, "highlightmatched" false }, "highlight" { "pre tags" \[ "\<b>" ], "post tags" \[ "\</b>" ] }, " source" "name" }, "tracking" "all" } following is the explanation of the important parameters involved in the code block above source this field defines the property that is to be returned to the user in the above example, 'name' will be returned suggest fields properties that are used for suggestions are defined in this field only the defined fields will be search while all the others will be ignored in the example above, that property is 'name' if no values are set in the field block, then all suggestable fields are searched by default query in this block, users can utilize the default opensearch queries to filter results, define filters, and other specific functionalities refer to this documentation to implement the various required features highlight this field sets the highlight tag users can define the pre and post tag in the example above, both are set to strong (bold)