You can download and run the sample code in Dot Net How To Autocomplete to evaluate these features.
The autocomplete Java Script API adds the term parameter.
Fuzzy search allows you to get results based on close matches even if the user misspells a word in the search box.
This library adds the autocomplete experience to the search box by making asynchronous calls to the MVC controller to retrieve suggestions.
The Java Script language version is in Index Java Script.cshtml.
So far, the search UX code has been centered on the suggestions.
The next code block shows the j Query UI Autocomplete function (line 91 in index.cshtml), passing in a request for Azure Search autocomplete: Now that we have reviewed the Java Script code for the web page, let's look at the C# server-side controller code that actually retrieves the suggested matches using the Azure Search . Open the Home file under the Controllers directory.
For both C# and Java Script versions, the search box implementation is exactly the same.
Open the Index.cshtml file under the folder \Views\Home to view the code: This example is a simple input text box with a class for styling, an ID to be referenced by Java Script, and placeholder text. The C# language sample uses Java Script in Index.cshtml to leverage the j Query UI Autocomplete library.
The NYCJobs index contains a Suggester construct, which is a requirement for using either suggestions or autocomplete.
You can use the prepared index hosted in a sandbox service, or populate your own index using a data loader in the NYCJobs sample solution.
Since this project is an MVC project, it calls the Suggest function in Home that contains the logic for returning query suggestions (more about Suggest in the next section).