@@ -108,21 +108,21 @@ AzureKeyCredential credential = new AzureKeyCredential("<Your search service adm
108
108
//AzureKeyCredential credential = new AzureKeyCredential(" Your search service admin key" );
109
109
110
110
// Create a SearchIndexClient to send create/delete index commands
111
- SearchIndexClient adminClient = new SearchIndexClient(serviceEndpoint, credential);
111
+ SearchIndexClient searchIndexClient = new SearchIndexClient(serviceEndpoint, credential);
112
112
113
113
// Create a SearchClient to load and query documents
114
114
string indexName = " hotels-quickstart" ;
115
- SearchClient srchclient = new SearchClient(serviceEndpoint, indexName, credential);
115
+ SearchClient searchClient = new SearchClient(serviceEndpoint, indexName, credential);
116
116
117
117
// Delete index if it exists
118
118
Console.WriteLine(" {0}" , " Deleting index...\n" );
119
- DeleteIndexIfExists(indexName, adminClient );
119
+ DeleteIndexIfExists(indexName, searchIndexClient );
120
120
121
121
// Create index
122
122
Console.WriteLine(" {0}" , " Creating index...\n" );
123
- CreateIndex(indexName, adminClient );
123
+ CreateIndex(indexName, searchIndexClient );
124
124
125
- SearchClient ingesterClient = adminClient .GetSearchClient(indexName);
125
+ SearchClient ingesterClient = searchIndexClient .GetSearchClient(indexName);
126
126
127
127
// Load documents
128
128
Console.WriteLine(" {0}" , " Uploading documents...\n" );
@@ -134,23 +134,23 @@ AzureKeyCredential credential = new AzureKeyCredential("<Your search service adm
134
134
135
135
// Call the RunQueries method to invoke a series of queries
136
136
Console.WriteLine(" Starting queries...\n" );
137
- RunQueries(srchclient );
137
+ RunQueries(searchClient );
138
138
139
139
// End the program
140
140
Console.WriteLine(" {0}" , " Complete. Press any key to end this program...\n" );
141
141
Console.ReadKey ();
142
142
}
143
143
144
144
// Delete the hotels-quickstart index to reuse its name
145
- private static void DeleteIndexIfExists(string indexName, SearchIndexClient adminClient )
145
+ private static void DeleteIndexIfExists(string indexName, SearchIndexClient searchIndexClient )
146
146
{
147
- adminClient .GetIndexNames ();
147
+ searchIndexClient .GetIndexNames ();
148
148
{
149
- adminClient .DeleteIndex(indexName);
149
+ searchIndexClient .DeleteIndex(indexName);
150
150
}
151
151
}
152
152
// Create hotels-quickstart index
153
- private static void CreateIndex(string indexName, SearchIndexClient adminClient )
153
+ private static void CreateIndex(string indexName, SearchIndexClient searchIndexClient )
154
154
{
155
155
FieldBuilder fieldBuilder = new FieldBuilder ();
156
156
var searchFields = fieldBuilder.Build(typeof(Hotel));
@@ -160,7 +160,7 @@ AzureKeyCredential credential = new AzureKeyCredential("<Your search service adm
160
160
var suggester = new SearchSuggester(" sg" , new[] { " HotelName" , " Category" , " Address/City" , " Address/StateProvince" });
161
161
definition.Suggesters.Add(suggester);
162
162
163
- adminClient .CreateOrUpdateIndex(definition);
163
+ searchIndexClient .CreateOrUpdateIndex(definition);
164
164
}
165
165
166
166
// Upload documents in a single Upload request.
@@ -266,7 +266,7 @@ AzureKeyCredential credential = new AzureKeyCredential("<Your search service adm
266
266
}
267
267
268
268
// Run queries, use WriteDocuments to print output
269
- private static void RunQueries(SearchClient srchclient )
269
+ private static void RunQueries(SearchClient searchClient )
270
270
{
271
271
SearchOptions options;
272
272
SearchResults< Hotel> response;
@@ -285,7 +285,7 @@ AzureKeyCredential credential = new AzureKeyCredential("<Your search service adm
285
285
options.Select.Add(" HotelName" );
286
286
options.Select.Add(" Rating" );
287
287
288
- response = srchclient .Search< Hotel>( " *" , options) ;
288
+ response = searchClient .Search< Hotel>( " *" , options) ;
289
289
WriteDocuments(response);
290
290
291
291
// Query 2
@@ -301,7 +301,7 @@ AzureKeyCredential credential = new AzureKeyCredential("<Your search service adm
301
301
options.Select.Add(" HotelName" );
302
302
options.Select.Add(" Rating" );
303
303
304
- response = srchclient .Search< Hotel>( " hotels" , options) ;
304
+ response = searchClient .Search< Hotel>( " hotels" , options) ;
305
305
WriteDocuments(response);
306
306
307
307
// Query 3
@@ -316,7 +316,7 @@ AzureKeyCredential credential = new AzureKeyCredential("<Your search service adm
316
316
options.Select.Add(" HotelName" );
317
317
options.Select.Add(" Tags" );
318
318
319
- response = srchclient .Search< Hotel>( " pool" , options) ;
319
+ response = searchClient .Search< Hotel>( " pool" , options) ;
320
320
WriteDocuments(response);
321
321
322
322
// Query 4 - Use Facets to return a faceted navigation structure for a given query
@@ -334,22 +334,22 @@ AzureKeyCredential credential = new AzureKeyCredential("<Your search service adm
334
334
options.Select.Add(" HotelName" );
335
335
options.Select.Add(" Category" );
336
336
337
- response = srchclient .Search< Hotel>( " *" , options) ;
337
+ response = searchClient .Search< Hotel>( " *" , options) ;
338
338
WriteDocuments(response);
339
339
340
340
// Query 5
341
341
Console.WriteLine(" Query #5: Look up a specific document...\n" );
342
342
343
343
Response< Hotel> lookupResponse;
344
- lookupResponse = srchclient .GetDocument< Hotel>( " 3" ) ;
344
+ lookupResponse = searchClient .GetDocument< Hotel>( " 3" ) ;
345
345
346
346
Console.WriteLine(lookupResponse.Value.HotelId);
347
347
348
348
349
349
// Query 6
350
350
Console.WriteLine(" Query #6: Call Autocomplete on HotelName...\n" );
351
351
352
- var autoresponse = srchclient .Autocomplete(" sa" , " sg" );
352
+ var autoresponse = searchClient .Autocomplete(" sa" , " sg" );
353
353
WriteDocuments(autoresponse);
354
354
355
355
}
@@ -651,11 +651,11 @@ static void Main(string[] args)
651
651
//AzureKeyCredential credential = new AzureKeyCredential("Your search service admin key");
652
652
653
653
// Create a SearchIndexClient to send create/delete index commands
654
- SearchIndexClient adminClient = new SearchIndexClient(serviceEndpoint, credential);
654
+ SearchIndexClient searchIndexClient = new SearchIndexClient(serviceEndpoint, credential);
655
655
656
656
// Create a SearchClient to load and query documents
657
657
string indexName = "hotels-quickstart";
658
- SearchClient srchclient = new SearchClient(serviceEndpoint, indexName, credential);
658
+ SearchClient searchClient = new SearchClient(serviceEndpoint, indexName, credential);
659
659
660
660
// REDACTED FOR BREVITY . . .
661
661
}
@@ -685,7 +685,7 @@ In *Program.cs*, you create a [SearchIndex](/dotnet/api/azure.search.documents.i
685
685
686
686
```csharp
687
687
// Create hotels-quickstart index
688
- private static void CreateIndex(string indexName, SearchIndexClient adminClient )
688
+ private static void CreateIndex(string indexName, SearchIndexClient searchIndexClient )
689
689
{
690
690
FieldBuilder fieldBuilder = new FieldBuilder();
691
691
var searchFields = fieldBuilder.Build(typeof(Hotel));
@@ -695,7 +695,7 @@ private static void CreateIndex(string indexName, SearchIndexClient adminClient)
695
695
var suggester = new SearchSuggester("sg", new[] { "HotelName", "Category", "Address/City", "Address/StateProvince" });
696
696
definition.Suggesters.Add(suggester);
697
697
698
- adminClient .CreateOrUpdateIndex(definition);
698
+ searchIndexClient .CreateOrUpdateIndex(definition);
699
699
}
700
700
```
701
701
@@ -741,10 +741,10 @@ private static void UploadDocuments(SearchClient searchClient)
741
741
742
742
Once you initialize the [IndexDocumentsBatch](/dotnet/api/azure.search.documents.models.indexdocumentsbatch-1) object, you can send it to the index by calling [IndexDocuments](/dotnet/api/azure.search.documents.searchclient.indexdocuments) on your [SearchClient](/dotnet/api/azure.search.documents.searchclient) object.
743
743
744
- You load documents using SearchClient in ` Main()` , but the operation also requires admin rights on the service, which is typically associated with SearchIndexClient. One way to set up this operation is to get SearchClient through ` SearchIndexClient` (` adminClient ` in this example).
744
+ You load documents using SearchClient in ` Main()` , but the operation also requires admin rights on the service, which is typically associated with SearchIndexClient. One way to set up this operation is to get SearchClient through ` SearchIndexClient` (` searchIndexClient ` in this example).
745
745
746
746
` ` ` csharp
747
- SearchClient ingesterClient = adminClient .GetSearchClient(indexName);
747
+ SearchClient ingesterClient = searchIndexClient .GetSearchClient(indexName);
748
748
749
749
// Load documents
750
750
Console.WriteLine(" {0}" , " Uploading documents...\n" );
@@ -796,11 +796,11 @@ private static void WriteDocuments(AutocompleteResults autoResults)
796
796
797
797
# ### Query example 1
798
798
799
- The ` RunQueries` method executes queries and returns results. Results are Hotel objects. This sample shows the method signature and the first query. This query demonstrates the Select parameter that lets you compose the result using selected fields from the document.
799
+ The ` RunQueries` method executes queries and returns results. Results are Hotel objects. This sample shows the method signature and the first query. This query demonstrates the ` Select` parameter that lets you compose the result using selected fields from the document.
800
800
801
801
` ` ` csharp
802
802
// Run queries, use WriteDocuments to print output
803
- private static void RunQueries(SearchClient srchclient )
803
+ private static void RunQueries(SearchClient searchClient )
804
804
{
805
805
SearchOptions options;
806
806
SearchResults< Hotel> response;
@@ -819,7 +819,7 @@ private static void RunQueries(SearchClient srchclient)
819
819
options.Select.Add(" HotelName" );
820
820
options.Select.Add(" Address/City" );
821
821
822
- response = srchclient .Search< Hotel>( " *" , options) ;
822
+ response = searchClient .Search< Hotel>( " *" , options) ;
823
823
WriteDocuments(response);
824
824
// REDACTED FOR BREVITY
825
825
}
@@ -843,7 +843,7 @@ options.Select.Add("HotelId");
843
843
options.Select.Add("HotelName");
844
844
options.Select.Add("Rating");
845
845
846
- response = srchclient .Search<Hotel>("hotels", options);
846
+ response = searchClient .Search<Hotel>("hotels", options);
847
847
WriteDocuments(response);
848
848
```
849
849
@@ -863,7 +863,7 @@ options.Select.Add("HotelId");
863
863
options.Select.Add("HotelName");
864
864
options.Select.Add("Tags");
865
865
866
- response = srchclient .Search<Hotel>("pool", options);
866
+ response = searchClient .Search<Hotel>("pool", options);
867
867
WriteDocuments(response);
868
868
```
869
869
@@ -886,7 +886,7 @@ options.Select.Add("HotelId");
886
886
options.Select.Add("HotelName");
887
887
options.Select.Add("Category");
888
888
889
- response = srchclient .Search<Hotel>("*", options);
889
+ response = searchClient .Search<Hotel>("*", options);
890
890
WriteDocuments(response);
891
891
```
892
892
@@ -899,7 +899,7 @@ In the fifth query, return a specific document. A document lookup is a typical r
899
899
Console.WriteLine("Query #5: Look up a specific document...\n");
900
900
901
901
Response<Hotel> lookupResponse;
902
- lookupResponse = srchclient .GetDocument<Hotel>("3");
902
+ lookupResponse = searchClient .GetDocument<Hotel>("3");
903
903
904
904
Console.WriteLine(lookupResponse.Value.HotelId);
905
905
```
@@ -912,7 +912,7 @@ The last query shows the syntax for autocomplete, simulating a partial user inpu
912
912
// Query 6
913
913
Console.WriteLine("Query #6: Call Autocomplete on HotelName that starts with ' sa' ...\n");
914
914
915
- var autoresponse = srchclient .Autocomplete("sa", "sg");
915
+ var autoresponse = searchClient .Autocomplete("sa", "sg");
916
916
WriteDocuments(autoresponse);
917
917
```
918
918
0 commit comments