You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Tutorial: Add autocomplete and suggestions using the .NET SDK
17
17
18
-
Learn how to implement autocomplete (typeahead queries and suggested results) when a user starts typing into a search box. In this tutorial, we will show autocompleted queries and suggested results separately, and then together. A user may only have to type two or three characters to locate all the results that are available.
18
+
Learn how to implement autocomplete (typeahead queries and suggested results) when a user starts typing into a search box. In this tutorial, we'll show autocompleted queries and suggested results separately, and then together. A user may only have to type two or three characters to locate all the results that are available.
19
19
20
20
In this tutorial, you learn how to:
21
21
> [!div class="checklist"]
@@ -82,7 +82,7 @@ Let's start with the simplest case of offering up alternatives to the user: a dr
2. Becausewe're introducing a new jQuery reference, we also need to remove, or comment out, the default jQuery reference in the _Layout.cshtml file (in the **Views/Shared** folder). Locate the following lines, and comment out the first script line as shown. This change avoids clashing references to jQuery.
86
86
87
87
```html
88
88
<environmentinclude="Development">
@@ -131,7 +131,7 @@ Let's start with the simplest case of offering up alternatives to the user: a dr
131
131
132
132
The**Size**parameterspecifieshowmanyresultstoreturn (ifunspecified, thedefaultis5). A_suggester_isspecifiedonthesearchindex when the index is created. In the sample hotels index hosted by Microsoft, the suggester name is "sg", and it searches for suggested matches exclusively in the **HotelName** field.
Fuzzymatchingallows "nearmisses" tobeincludedintheoutput, uptooneeditdistance. Ifthe**highlights**parameterissettotrue, thenboldHTMLtagsareaddedtotheoutput. We'll set both parameters to true in the next section.
@@ -150,7 +150,7 @@ Let's start with the simplest case of offering up alternatives to the user: a dr
150
150
151
151
:::imagetype="content"source="media/tutorial-csharp-create-first-app/azure-search-suggest-fuzzy.png"alt-text="Typing *pa* with fuzzy set to true"border="false":::
152
152
153
-
Ifyouareinterested, the [LucenequerysyntaxinAzureCognitiveSearch](./query-lucene-syntax.md) describesthelogicusedinfuzzysearchesindetail.
153
+
Ifyou're interested, the [Lucene query syntax in Azure Cognitive Search](./query-lucene-syntax.md) describes the logic used in fuzzy searches in detail.
154
154
155
155
## Add highlighting to the suggestions
156
156
@@ -195,13 +195,13 @@ We can improve the appearance of the suggestions to the user by setting the **hi
195
195
196
196
:::imagetype="content"source="media/tutorial-csharp-create-first-app/azure-search-suggest-highlight.png"alt-text="Typing *pa* with highlighting"border="false":::
Thelogicusedinthehighlightingscriptaboveisn't foolproof. If you enter a term that appears twice in the same name, the bolded results aren'tquitewhatyouwouldwant. Trytyping"mo".
199
199
200
-
Oneofthequestionsadeveloperneedstoansweris, whenisascriptworking "wellenough", andwhenshoulditsquirksbeaddressed. Wewillnotbetakinghighlightinganyfurtherinthistutorial, butfindingaprecisealgorithmissomethingtoconsiderifhighlightingisnoteffectiveforyourdata. Formoreinformation, see [Hithighlighting](search-pagination-page-layout.md#hit-highlighting).
200
+
Oneofthequestionsadeveloperneedstoansweris, whenisascriptworking "wellenough", andwhenshoulditsquirksbeaddressed. Wewon't be taking highlighting any further in this tutorial, but finding a precise algorithm is something to consider if highlighting isn'teffectiveforyourdata. Formoreinformation, see [Hithighlighting](search-pagination-page-layout.md#hit-highlighting).
Anothervariation, slightlydifferentfromsuggestions, isautocompletion (sometimescalled "type-ahead") thatcompletesaqueryterm. Again, we'll start with the simplest implementation, before improving the user experience.
Noticethatwe're using the same *suggester* function, called "sg", in the autocomplete search as we did for suggestions (so we'reonlytryingtoautocompletethehotelnames).
Therearearangeof**AutocompleteMode**settings, andwe're using **OneTermWithContext**. Refer to [Autocomplete API](/rest/api/searchservice/autocomplete) for a description of additional options.
Therearelibrariesthatofferthisfunctionality-oftencalled"inline autocompletion"orasimilarname. However, wearegoingtonativelyimplementthisfeaturesothatyoucanexploretheAPIs. Wearegoingtostartworkonthecontrollerfirstinthisexample.
263
+
Therearelibrariesthatofferthisfunctionality - oftencalled "inlineautocompletion" orasimilarname. However, we'regoingtonativelyimplementthisfeaturesothatyoucanexploretheAPIs. We'regoingtostartworkonthecontrollerfirstinthisexample.
1. Alsointheview, enterthefollowingscript, afterallthescriptsyou've entered so far. The script is lengthy and complex due to the variety of input behaviors that it handles.
331
331
332
332
```javascript
333
333
<script>
@@ -452,7 +452,7 @@ There are libraries that offer this functionality - often called "inline autocom
0 commit comments