Skip to content

Commit 6484d1b

Browse files
authored
[C#] Code Snippet for Atlas Search Autocomplete doesn't work (#177)
* add note about search index
1 parent 2adb373 commit 6484d1b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

source/fundamentals/atlas-search.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ collection using the string "Gib" in the ``make`` field.
106106
:language: csharp
107107
:dedent:
108108

109+
.. note::
110+
111+
If the field you are searching on is indexed by a search index, you must pass the index name to the ``Autocomplete`` call. If a search index does not exist, the default index is used.
112+
109113
The search returns the following document:
110114

111115
.. code-block:: json

source/includes/fundamentals/code-examples/atlas-search/AtlasSearchExamples.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static List<Guitar> AutocompleteSearch()
2929
// Finds documents with a "make" value that contains the string fragment "Gib"
3030
// start-autocomplete-search
3131
var result = guitarsCollection.Aggregate()
32-
.Search(Builders<Guitar>.Search.Autocomplete(g => g.Make, "Gib"))
32+
.Search(Builders<Guitar>.Search.Autocomplete(g => g.Make, "Gib"), indexName: "guitarmakes")
3333
.ToList();
3434
// end-autocomplete-search
3535

0 commit comments

Comments
 (0)