Skip to content

Commit 446e884

Browse files
authored
Merge pull request #209588 from HeidiSteen/heidist-fresh
[azure search] Freshness pass on c# quickstart plus screenshot updates
2 parents 6c9d8d5 + 06a309a commit 446e884

File tree

10 files changed

+38
-22
lines changed

10 files changed

+38
-22
lines changed
24.8 KB
Loading
-225 Bytes
Loading
13.1 KB
Loading
9.73 KB
Loading
5.82 KB
Loading
24.8 KB
Loading

articles/search/search-get-started-dotnet.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ms.custom: devx-track-csharp, mode-api
1313
---
1414
# Quickstart: Create a search index using the Azure.Search.Documents client library
1515

16-
Use the [Azure.Search.Documents (version 11) client library](/dotnet/api/overview/azure/search.documents-readme) to create a .NET Core console application in C# that creates, loads, and queries a search index.
16+
Learn how to use the [Azure.Search.Documents (version 11) client library](/dotnet/api/overview/azure/search.documents-readme) to create a .NET Core console application in C# that creates, loads, and queries a search index.
1717

1818
You can [download the source code](https://github.com/Azure-Samples/azure-search-dotnet-samples/tree/master/quickstart/v11) to start with a finished project or follow the steps in this article to create your own.
1919

@@ -32,11 +32,10 @@ Before you begin, have the following tools and services:
3232

3333
When setting up your project, you'll download the [Azure.Search.Documents NuGet package](https://www.nuget.org/packages/Azure.Search.Documents/).
3434

35-
Azure SDK for .NET conforms to [.NET Standard 2.0](/dotnet/standard/net-standard#net-implementation-support), which means .NET Framework 4.6.1 and .NET Core 2.0 as minimum requirements.
36-
35+
Azure SDK for .NET conforms to [.NET Standard 2.0](/dotnet/standard/net-standard#net-implementation-support), which means .NET Framework 4.6.1 and .NET Core 2.1 as minimum requirements.
3736
## Set up your project
3837

39-
Assemble service connection information, and then start Visual Studio to create a new Console App project that can run on .NET Core.
38+
Assemble service connection information, and then start Visual Studio to create a new Console App project that can run on. Select NET Core 3.1 for the run time.
4039

4140
<a name="get-service-info"></a>
4241

@@ -81,11 +80,11 @@ After the project is created, add the client library. The [Azure.Search.Document
8180
1. Create two clients: [SearchIndexClient](/dotnet/api/azure.search.documents.indexes.searchindexclient) creates the index, and [SearchClient](/dotnet/api/azure.search.documents.searchclient) loads and queries an existing index. Both need the service endpoint and an admin API key for authentication with create/delete rights.
8281

8382
```csharp
84-
static void Main(string[] args)
85-
{
86-
string serviceName = "<YOUR-SERVICE-NAME>";
87-
string indexName = "hotels-quickstart";
88-
string apiKey = "<YOUR-ADMIN-API-KEY>";
83+
static void Main(string[] args)
84+
{
85+
string serviceName = "<your-search-service-name>";
86+
string apiKey = "<your-search-service-admin-api-key>";
87+
string indexName = "hotels-quickstart";
8988

9089
// Create a SearchIndexClient to send create/delete index commands
9190
Uri serviceEndpoint = new Uri($"https://{serviceName}.search.windows.net/");
@@ -94,6 +93,8 @@ After the project is created, add the client library. The [Azure.Search.Document
9493

9594
// Create a SearchClient to load and query documents
9695
SearchClient srchclient = new SearchClient(serviceEndpoint, indexName, credential);
96+
. . .
97+
}
9798
```
9899

99100
## 1 - Create an index
@@ -364,6 +365,16 @@ The [SearchResults](/dotnet/api/azure.search.documents.models.searchresults-1) c
364365

365366
Console.WriteLine();
366367
}
368+
369+
private static void WriteDocuments(AutocompleteResults autoResults)
370+
{
371+
foreach (AutocompleteItem result in autoResults.Results)
372+
{
373+
Console.WriteLine(result.Text);
374+
}
375+
376+
Console.WriteLine();
377+
}
367378
```
368379

369380
1. Create a **RunQueries** method to execute queries and return 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.
@@ -374,7 +385,8 @@ The [SearchResults](/dotnet/api/azure.search.documents.models.searchresults-1) c
374385
{
375386
SearchOptions options;
376387
SearchResults<Hotel> response;
377-
388+
389+
// Query 1
378390
Console.WriteLine("Query #1: Search on empty term '*' to return all documents, showing a subset of fields...\n");
379391

380392
options = new SearchOptions()
@@ -395,6 +407,7 @@ The [SearchResults](/dotnet/api/azure.search.documents.models.searchresults-1) c
395407
1. In the second query, search on a term, add a filter that selects documents where Rating is greater than 4, and then sort by Rating in descending order. Filter is a boolean expression that is evaluated over [IsFilterable](/dotnet/api/azure.search.documents.indexes.models.searchfield.isfilterable) fields in an index. Filter queries either include or exclude values. As such, there's no relevance score associated with a filter query.
396408

397409
```csharp
410+
// Query 2
398411
Console.WriteLine("Query #2: Search on 'hotels', filter on 'Rating gt 4', sort by Rating in descending order...\n");
399412

400413
options = new SearchOptions()
@@ -414,6 +427,7 @@ The [SearchResults](/dotnet/api/azure.search.documents.models.searchresults-1) c
414427
1. The third query demonstrates searchFields, used to scope a full text search operation to specific fields.
415428

416429
```csharp
430+
// Query 3
417431
Console.WriteLine("Query #3: Limit search to specific fields (pool in Tags field)...\n");
418432

419433
options = new SearchOptions()
@@ -432,6 +446,7 @@ The [SearchResults](/dotnet/api/azure.search.documents.models.searchresults-1) c
432446
1. The fourth query demonstrates facets, which can be used to structure a faceted navigation structure.
433447

434448
```csharp
449+
// Query 4
435450
Console.WriteLine("Query #4: Facet on 'Category'...\n");
436451

437452
options = new SearchOptions()
@@ -452,6 +467,7 @@ The [SearchResults](/dotnet/api/azure.search.documents.models.searchresults-1) c
452467
1. In the fifth query, return a specific document. A document lookup is a typical response to OnClick event in a result set.
453468

454469
```csharp
470+
// Query 5
455471
Console.WriteLine("Query #5: Look up a specific document...\n");
456472

457473
Response<Hotel> lookupResponse;
@@ -463,12 +479,12 @@ The [SearchResults](/dotnet/api/azure.search.documents.models.searchresults-1) c
463479
1. The last query shows the syntax for autocomplete, simulating a partial user input of "sa" that resolves to two possible matches in the sourceFields associated with the suggester you defined in the index.
464480

465481
```csharp
482+
// Query 6
466483
Console.WriteLine("Query #6: Call Autocomplete on HotelName that starts with 'sa'...\n");
467484

468485
var autoresponse = srchclient.Autocomplete("sa", "sg");
469486
WriteDocuments(autoresponse);
470487
```
471-
472488
1. Add **RunQueries** to Main().
473489

474490
```csharp

articles/search/search-get-started-java.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: 'Quickstart: Create a search index in Javas'
2+
title: 'Quickstart: Create a search index in Java'
33
titleSuffix: Azure Cognitive Search
44
description: In this Java quickstart, learn how to create an index, load data, and run queries using the Azure Cognitive Search client library for Java.
55
manager: nitinme

articles/search/search-get-started-python.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ms.custom: devx-track-python, mode-api
2222
> * [Portal](search-get-started-portal.md)
2323
>
2424
25-
Build a notebook that creates, loads, and queries an Azure Cognitive Search index using Python and the [azure-search-documents library](/python/api/overview/azure/search-documents-readme) in the Azure SDK for Python. This article explains how to build a notebook step by step. Alternatively, you can [download and run a finished Jupyter Python notebook](https://github.com/Azure-Samples/azure-search-python-samples).
25+
Build a Jupyter Notebook that creates, loads, and queries an Azure Cognitive Search index using Python and the [azure-search-documents library](/python/api/overview/azure/search-documents-readme) in the Azure SDK for Python. This article explains how to build a notebook step by step. Alternatively, you can [download and run a finished Jupyter Python notebook](https://github.com/Azure-Samples/azure-search-python-samples).
2626

2727
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
2828

@@ -57,8 +57,8 @@ In this task, start Jupyter Notebook and verify that you can connect to Azure Co
5757
1. In the first cell, load the libraries from the Azure SDK for Python, including [azure-search-documents](/python/api/azure-search-documents).
5858

5959
```python
60-
!pip install azure-search-documents --pre
61-
!pip show azure-search-documents
60+
%pip install azure-search-documents --pre
61+
%pip show azure-search-documents
6262

6363
import os
6464
from azure.core.credentials import AzureKeyCredential
@@ -318,7 +318,7 @@ This step shows you how to query an index using the **search** method of the [se
318318
print(" {}".format(facet))
319319
```
320320

321-
1. In this example, look up a specific document based on its key. You would typically want to return a document when a user select on a document in a search result.
321+
1. In this example, look up a specific document based on its key. You would typically want to return a document when a user selects a document in a search result.
322322

323323
```python
324324
result = search_client.get_document(key="3")
@@ -331,7 +331,7 @@ This step shows you how to query an index using the **search** method of the [se
331331

332332
1. In this example, we'll use the autocomplete function. Autocomplete is typically used in a search box to provide potential matches as the user types into the search box.
333333

334-
When the index was created, a suggester named "sg" was also created as part of the request. A suggester definition specifies which fields can be used to find potential matches to suggester requests. In this example, those fields are 'Tags', 'Address/City', 'Address/Country'. To simulate auto-complete, pass in the letters "sa" as a partial string. The autocomplete method of [SearchClient](/python/api/azure-search-documents/azure.search.documents.searchclient) sends back potential term matches.
334+
When the index was created, a suggester named `sg` was also created as part of the request. A suggester definition specifies which fields can be used to find potential matches to suggester requests. In this example, those fields are 'Tags', 'Address/City', 'Address/Country'. To simulate auto-complete, pass in the letters "sa" as a partial string. The autocomplete method of [SearchClient](/python/api/azure-search-documents/azure.search.documents.searchclient) sends back potential term matches.
335335

336336
```python
337337
search_suggestion = 'sa'

articles/search/tutorial-multiple-data-sources.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,19 @@ This sample uses two small sets of data that describe seven fictional hotels. On
6464

6565
1. Select **Data Explorer** and then select **New Database**.
6666

67-
:::image type="content" source="media/tutorial-multiple-data-sources/cosmos-newdb.png" alt-text="Create a new database" border="false":::
67+
:::image type="content" source="media/tutorial-multiple-data-sources/cosmos-newdb.png" alt-text="Create a new database" border="true":::
6868

6969
1. Enter the name **hotel-rooms-db**. Accept default values for the remaining settings.
7070

71-
:::image type="content" source="media/tutorial-multiple-data-sources/cosmos-dbname.png" alt-text="Configure database" border="false":::
71+
:::image type="content" source="media/tutorial-multiple-data-sources/cosmos-dbname.png" alt-text="Configure database" border="true":::
7272

7373
1. Create a new container. Use the existing database you just created. Enter **hotels** for the container name, and use **/HotelId** for the Partition key.
7474

75-
:::image type="content" source="media/tutorial-multiple-data-sources/cosmos-add-container.png" alt-text="Add container" border="false":::
75+
:::image type="content" source="media/tutorial-multiple-data-sources/cosmos-add-container.png" alt-text="Add container" border="true":::
7676

7777
1. Select **Items** under **hotels**, and then select **Upload Item** on the command bar. Navigate to and then select the file **cosmosdb/HotelsDataSubset_CosmosDb.json** in the project folder.
7878

79-
:::image type="content" source="media/tutorial-multiple-data-sources/cosmos-upload.png" alt-text="Upload to Azure Cosmos DB collection" border="false":::
79+
:::image type="content" source="media/tutorial-multiple-data-sources/cosmos-upload.png" alt-text="Upload to Azure Cosmos DB collection" border="true":::
8080

8181
1. Use the Refresh button to refresh your view of the items in the hotels collection. You should see seven new database documents listed.
8282

@@ -88,7 +88,7 @@ This sample uses two small sets of data that describe seven fictional hotels. On
8888

8989
1. [Create a blob container](../storage/blobs/storage-quickstart-blobs-portal.md) named **hotel-rooms** to store the sample hotel room JSON files. You can set the Public Access Level to any of its valid values.
9090

91-
:::image type="content" source="media/tutorial-multiple-data-sources/blob-add-container.png" alt-text="Create a blob container" border="false":::
91+
:::image type="content" source="media/tutorial-multiple-data-sources/blob-add-container.png" alt-text="Create a blob container" border="true":::
9292

9393
1. After the container is created, open it and select **Upload** on the command bar. Navigate to the folder containing the sample files. Select all of them and then select **Upload**.
9494

0 commit comments

Comments
 (0)