Suggestions?&& Try The Games



Noun suggestion (countable and uncountable, plural suggestions) (countable) Something suggested (with subsequent adposition being for) I have a small suggestion for fixing this: try lifting the left side up a bit. Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.

-->

Search-as-you-type is a common technique for improving the productivity of user-initiated queries. In Azure Cognitive Search, this experience is supported through autocomplete, which finishes a term or phrase based on partial input (completing 'micro' with 'microsoft'). A second user experience is suggestions, or a short list of matching documents (returning book titles with an ID so that you can link to a detail page about that book). Both autocomplete and suggestions are predicated on a match in the index. The service won't offer queries that return zero results.

To implement these experiences in Azure Cognitive Search, you will need:

  • A suggester definition that's embedded in the index schema.
  • A query specifying Autocomplete or Suggestions API on the request.
  • A UI control to handle search-as-you-type interactions in your client app. We recommend using an existing JavaScript library for this purpose.

In Azure Cognitive Search, autocompleted queries and suggested results are retrieved from the search index, from selected fields that you have registered with a suggester. A suggester is part of the index, and it specifies which fields will provide content that either completes a query, suggests a result, or does both. When the index is created and loaded, a suggester data structure is created internally to store prefixes used for matching on partial queries. For suggestions, choosing suitable fields that are unique, or at least not repetitive, is essential to the experience. For more information, see Create a suggester.

The remainder of this article is focused on queries and client code. It uses JavaScript and C# to illustrate key points. REST API examples are used to concisely present each operation. For links to end-to-end code samples, see Next steps.

Set up a request

Elements of a request include one of the search-as-you-type APIs, a partial query, and a suggester. The following script illustrates components of a request, using the Autocomplete REST API as an example.

The suggesterName gives you the suggester-aware fields used to complete terms or suggestions. For suggestions in particular, the field list should be composed of those that offer clear choices among matching results. On a site that sells computer games, the field might be the game title.

The search parameter provides the partial query, where characters are fed to the query request through the jQuery Autocomplete control. In the above example, 'minecraf' is a static illustration of what the control might have passed in.

The APIs do not impose minimum length requirements on the partial query; it can be as little as one character. However, jQuery Autocomplete provides a minimum length. A minimum of two or three characters is typical.

Matches are on the beginning of a term anywhere in the input string. Given 'the quick brown fox', both autocomplete and suggestions will match on partial versions of 'the', 'quick', 'brown', or 'fox' but not on partial infix terms like 'rown' or 'ox'. Furthermore, each match sets the scope for downstream expansions. A partial query of 'quick br' will match on 'quick brown' or 'quick bread', but neither 'brown' or 'bread' by themselves would be match unless 'quick' precedes them.

APIs for search-as-you-type

Follow these links for the REST and .NET SDK reference pages:

Structure a response

Responses for autocomplete and suggestions are what you might expect for the pattern: Autocomplete returns a list of terms, Suggestions returns terms plus a document ID so that you can fetch the document (use the Lookup Document API to fetch the specific document for a detail page).

Responses are shaped by the parameters on the request. For Autocomplete, set autocompleteMode to determine whether text completion occurs on one or two terms. For Suggestions, the field you choose determines the contents of the response.

For suggestions, you should further refine the response to avoid duplicates or what appears to be unrelated results. To control results, include more parameters on the request. The following parameters apply to both autocomplete and suggestions, but are perhaps more necessary for suggestions, especially when a suggester includes multiple fields.

ParameterUsage
$selectIf you have multiple sourceFields in a suggester, use $select to choose which field contributes values ($select=GameTitle).
searchFieldsConstrain the query to specific fields.
$filterApply match criteria on the result set ($filter=Category eq 'ActionAdventure').
$topLimit the results to a specific number ($top=5).

Add user interaction code

Auto-filling a query term or dropping down a list of matching links requires user interaction code, typically JavaScript, that can consume requests from external sources, such as autocomplete or suggestion queries against an Azure Search Cognitive index.

Although you could write this code natively, it's much easier to use functions from existing JavaScript library. This article demonstrates two, one for suggestions and another for autocomplete.

  • Autocomplete widget (jQuery UI) is used in the Suggestion example. You can create a search box, and then reference it in a JavaScript function that uses the Autocomplete widget. Properties on the widget set the source (an autocomplete or suggestions function), minimum length of input characters before action is taken, and positioning.

  • XDSoft Autocomplete plug-in is used the Autocomplete example.

We use these libraries to build the search box supporting both suggestions and autocomplete. Inputs collected in the search box are paired with suggestions and autocomplete actions.

Suggestions

This section walks you through an implementation of suggested results, starting with the search box definition. It also shows how and script that invokes the first JavaScript autocomplete library referenced in this article.

Create a search box

Assuming the jQuery UI Autocomplete library and an MVC project in C#, you could define the search box using JavaScript in the Index.cshtml file. The library adds the search-as-you-type interaction to the search box by making asynchronous calls to the MVC controller to retrieve suggestions.

In Index.cshtml under the folder ViewsHome, a line to create a search box might be as follows:

This example is a simple input text box with a class for styling, an ID to be referenced by JavaScript, and placeholder text.

Within the same file, embed JavaScript that references the search box. The following function calls the Suggest API, which requests suggested matching documents based on partial term inputs:

The source tells the jQuery UI Autocomplete function where to get the list of items to show under the search box. Since this project is an MVC project, it calls the Suggest function in HomeController.cs that contains the logic for returning query suggestions. This function also passes a few parameters to control highlights, fuzzy matching, and term. The autocomplete JavaScript API adds the term parameter.

The minLength: 3 ensures that recommendations will only be shown when there are at least three characters in the search box.

Enable fuzzy matching

Fuzzy search allows you to get results based on close matches even if the user misspells a word in the search box. The edit distance is 1, which means there can be a maximum discrepancy of one character between the user input and a match.

Enable highlighting

Highlighting applies font style to the characters in the result that correspond to the input. For example, if the partial input is 'micro', the result would appear as microsoft, microscope, and so forth. Highlighting is based on the HighlightPreTag and HighlightPostTag parameters, defined inline with the Suggestion function.

Suggest function

If you are using C# and an MVC application, HomeController.cs file under the Controllers directory is where you might create a class for suggested results. In .NET, a Suggest function is based on the SuggestAsync method. For more information about the .NET SDK, see How to use Azure Cognitive Search from a .NET Application.

The InitSearch method creates an authenticated HTTP index client to the Azure Cognitive Search service. Properties on the SuggestOptions class determine which fields are searched and returned in the results, the number of matches, and whether fuzzy matching is used.

For autocomplete, fuzzy matching is limited to one edit distance (one omitted or misplaced character). Note that fuzzy matching in autocomplete queries can sometimes produce unexpected results depending on index size and how it's sharded. For more information, see partition and sharding concepts.

The SuggestAsync function takes two parameters that determine whether hit highlights are returned or fuzzy matching is used in addition to the search term input. Up to eight matches can be included in suggested results. The method creates a SuggestOptions object, which is then passed to the Suggest API. The result is then converted to JSON so it can be shown in the client.

Suggestions

Autocomplete

So far, the search UX code has been centered on suggestions. The next code block shows autocomplete, using the XDSoft jQuery UI Autocomplete function, passing in a request for Azure Cognitive Search autocomplete. As with the suggestions, in a C# application, code that supports user interaction goes in index.cshtml.

Autocomplete function

Autocomplete is based on the AutocompleteAsync method. As with suggestions, this code block would go in the HomeController.cs file.

The Autocomplete function takes the search term input. The method creates an AutoCompleteParameters object. The result is then converted to JSON so it can be shown in the client.

Next steps

Follow these links for end-to-end instructions or code demonstrating both search-as-you-type experiences. Both code examples include hybrid implementations of suggestions and autocomplete together.


Also found in: Dictionary, Medical, Legal, Idioms, Encyclopedia, Wikipedia.
Graphic Thesaurus 🔍
</>embed</>
  • noun

Synonyms for suggestion

recommendation

Synonyms

hint

trace

Synonyms

Synonyms for suggestion

Suggestions && Try The Games Play

something that is put forward for consideration

something, such as a feeling, thought, or idea, associated in one's mind or imagination with a specific person or thing

a subtle pointing out

a slight amount or indication

Synonyms

  • soupçon

Synonyms for suggestion

an idea that is suggested

Related Words

a proposal offered for acceptance or rejection

Related Words

a just detectable amount

Related Words

persuasion formulated as a suggestion

Suggestions && Try The Games Free

Related Words

the sequential mental process in which one thought leads to another by association

the act of inducing hypnosis

Related Words


Want to thank TFD for its existence? Tell a friend about us, add a link to this page, or visit the webmaster's page for free fun content.
Link to this page: