Skip to content

Commit 54a42d1

Browse files
committed
Replace c#tutorial, phase 1
1 parent 0a8dea8 commit 54a42d1

9 files changed

+80
-25
lines changed

articles/search/TOC.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@
7676
- name: Deploy static web app
7777
href: tutorial-python-deploy-static-web-app.md
7878
- name: Explore the code
79-
href: tutorial-python-search-query-integration.md
79+
href: tutorial-python-search-query-integration.md
80+
- name: Add search to ASP.NET Core (MVC)
81+
href: tutorial-csharp-create-mvc-app.md
8082
- name: Index with indexers
8183
items:
8284
- name: Index Azure SQL Database
@@ -105,18 +107,6 @@
105107
href: tutorial-create-custom-analyzer.md
106108
- name: Query from Power Apps
107109
href: search-howto-powerapps.md
108-
- name: Create a C# app
109-
items:
110-
- name: 1 - Basic search page
111-
href: tutorial-csharp-create-first-app.md
112-
- name: 2 - Add results paging
113-
href: tutorial-csharp-paging.md
114-
- name: 3 - Add type-ahead
115-
href: tutorial-csharp-type-ahead-and-suggestions.md
116-
- name: 4 - Add facets
117-
href: tutorial-csharp-facets.md
118-
- name: 5 - Add results ordering
119-
href: tutorial-csharp-orders.md
120110
- name: Samples
121111
items:
122112
- name: C# samples

articles/search/index-add-suggesters.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,6 @@ POST /indexes/myxboxgames/docs/autocomplete?search&api-version=2020-06-30
169169

170170
+ [Add search to a web site (JavaScript)](tutorial-javascript-search-query-integration.md#azure-function-suggestions-from-the-catalog) uses an open source Suggestions package for partial term completion in the client app.
171171

172-
+ [Create your first app in C# (lesson 3 - Add search-as-you-type)](tutorial-csharp-type-ahead-and-suggestions.md) sample demonstrates suggested queries, autocomplete, and faceted navigation. This code provides native support for typeahead instead of using a widget.
173-
174172
## Next steps
175173

176174
Learn more about requests\ formulation.
81.9 KB
Loading

articles/search/samples-dotnet.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Code samples from the Cognitive Search team demonstrate features and workflows.
5454
| [multiple-data-sources](https://github.com/Azure-Samples/azure-search-dotnet-samples/tree/master/multiple-data-sources) | [Tutorial: Index from multiple data sources](tutorial-multiple-data-sources.md). | Merges content from two data sources into one search index.
5555
| [Optimize-data-indexing](https://github.com/Azure-Samples/azure-search-dotnet-samples/tree/master/optimize-data-indexing) | [Tutorial: Optimize indexing with the push API](tutorial-optimize-indexing-push-api.md).| Demonstrates optimization techniques for pushing data into a search index. |
5656
| [tutorial-ai-enrichment](https://github.com/Azure-Samples/azure-search-dotnet-samples/tree/master/tutorial-ai-enrichment) | [Tutorial: AI-generated searchable content from Azure blobs](cognitive-search-tutorial-blob-dotnet.md) | Shows how to configure an indexer and skillset. |
57-
| [Create your first app in C#](https://github.com/Azure-Samples/azure-search-dotnet-samples/tree/master/create-first-app/v11) | [Tutorial: Create your first search app](tutorial-csharp-create-first-app.md) | While most samples are console applications, this MVC sample uses a web page to front the sample Hotels index, demonstrating basic search, pagination, autocomplete and suggested queries, facets, and filters.|
57+
| [create-mvc-app](https://github.com/Azure-Samples/azure-search-dotnet-samples/tree/master/create-mvc-app) | [Tutorial: Add search to an ASP.NET Core (MVC) app](tutorial-csharp-create-mvc-app.md) | While most samples are console applications, this MVC sample uses a web page to front the sample Hotels index, demonstrating basic search, pagination, and other server-side behaviors.|
5858

5959
## Other samples
6060

articles/search/search-blob-storage-integration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ The output of an indexer is a search index, used for interactive exploration usi
132132
+ [Full query syntax](query-lucene-syntax.md)
133133
+ [Filter expression syntax](query-odata-filter-orderby-syntax.md)
134134

135-
A more permanent solution is to gather query inputs and present the response as search results in a client application. The following C# tutorial explains how to build a search application: [Create your first application in Azure Cognitive Search](tutorial-csharp-create-first-app.md).
135+
A more permanent solution is to gather query inputs and present the response as search results in a client application. The following C# tutorial explains how to build a search application: [Add search to an ASP.NET Core (MVC) application](tutorial-csharp-create-mvc-app.md).
136136

137137
## Next steps
138138

articles/search/search-faceted-navigation.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Facets are dynamic and returned on a query. A search response brings with it all
3131

3232
In Cognitive Search, facets are one layer deep and can't be hierarchical. If you aren't familiar with faceted navigation structured, the following example shows one on the left. Counts indicate the number of matches for each facet. The same document can be represented in multiple facets.
3333

34-
:::image source="media/tutorial-csharp-create-first-app/azure-search-facet-nav.png" alt-text="faceted search results":::
34+
:::image source="media/search-faceted-navigation/azure-search-facet-nav.png" alt-text="Screenshot of faceted search results.":::
3535

3636
Facets can help you find what you're looking for, while ensuring that you don't get zero results. As a developer, facets let you expose the most useful search criteria for navigating your search index.
3737

@@ -287,10 +287,6 @@ If you build the list of facets dynamically based on untrusted user input, valid
287287

288288
Several samples include faceted navigation. This section has links to the samples and also notes which client library and language is used for each one.
289289

290-
### Create your first app in C# (Razor)
291-
292-
This tutorial and sample series in C# includes a [lesson focused on faceted navigation](tutorial-csharp-facets.md). The solution is an ASP.NET MVC app and the presentation layer uses the Razor client libraries.
293-
294290
### Add search to web apps (React)
295291

296292
Tutorials and samples in [C#](tutorial-csharp-overview.md), [Python](tutorial-python-overview.md), and [JavaScript](tutorial-javascript-overview.md) include faceted navigation as well as filters, suggestions, and autocomplete. These samples use React for the presentation layer.

articles/search/search-pagination-page-layout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,6 @@ To quickly generate a search page for your client, consider these options:
298298

299299
+ [Application Generator](search-create-app-portal.md), in the portal, creates an HTML page with a search bar, faceted navigation, and results area that includes images.
300300

301-
+ [Create your first app in C#](tutorial-csharp-create-first-app.md) is a tutorial and code sample that builds a functional client. Sample code demonstrates paginated queries, hit highlighting, and sorting.
301+
+ [Add search to an ASP.NET Core (MVC) app](tutorial-csharp-create-mvc-app.md) is a tutorial and code sample that builds a functional client.
302302

303303
+ [Add search to web apps](tutorial-csharp-overview.md) is a tutorial and code sample that uses the React JavaScript libraries for the user experience. The app is deployed using Azure Static Web Apps.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
title: Add search to ASP.NET Core MVC
3+
titleSuffix: Azure Cognitive Search
4+
description: In this Azure Cognitive Search tutorial, learn how to add search to an ASP.NET Core (Model-View-Controller) application.
5+
6+
manager: nitinme
7+
author: HeidiSteen
8+
ms.author: heidist
9+
ms.service: cognitive-search
10+
ms.devlang: csharp
11+
ms.topic: tutorial
12+
ms.date: 03/09/2023
13+
---
14+
# Create a search app in ASP.NET Core
15+
16+
In this tutorial, create a basic ASP.NET Core (Model-View-Controller) app that connects to the hotels-sample-index on your search service for server-side operations. Search can return sorted, filtered, and boosted results.
17+
18+
Sample code this tutorial can be found in the [azure-search-dotnet-samples](https://github.com/Azure-Samples/azure-search-dotnet-samples/tree/main/create-mvc-app) repository on GitHub.
19+
20+
## Prerequisites
21+
22+
+ [Hotel samples index](search-get-started-portal.md)
23+
+ [Visual Studio](https://visualstudio.microsoft.com/downloads/)
24+
+ [Azure.Search.Documents NuGet package](https://www.nuget.org/packages/Azure.Search.Documents/)
25+
+ [Microsoft.Spatial NuGet package](https://www.nuget.org/packages/Microsoft.Spatial/)
26+
27+
To complete this tutorial, you'll need to create the hotels-sample-index on your search service. Make sure the search index name is`hotels-sample-index`, or change the index name in the `HomeController.cs` file.
28+
29+
Your search service must have public network access. For the connection, the app presents a query API key to your fully-qualified search URL. Both the URL and the query API key are specified in an `appsettings.json` file.
30+
31+
## Set up the project
32+
33+
1. Clone or download this sample repository.
34+
35+
1. Extract contents if the download is a zip file. Make sure the files are read-write.
36+
37+
1. Open the solution in Visual Studio.
38+
39+
1. If necessary, update the NuGet packages to get the most recent stable versions.
40+
41+
1. Modify `appsettings.json` to specify your search service and query API key.
42+
43+
```json
44+
{
45+
"SearchServiceName": "https://<YOUR-SEARCH-SERVICE-NAME>.search.windows.net",
46+
"SearchServiceQueryApiKey": "<YOUR-SEARCH-SERVICE-QUERY-API-KEY>"
47+
}
48+
```
49+
50+
## Run the sample
51+
52+
1. Press **F5** to compile and run the project. The app runs on local host and opens in your default browser.
53+
54+
1. Select the **Search** button to return all results.
55+
56+
1. This demo uses the default search configuration, supporting the [simple syntax](query-simple-syntax.md) and `searchMode=Any`. You can enter keywords with boolean operators.
57+
58+
1. To change server-side behaviors, modify the **RunQueryAsync** method in the HomeController. There are several use-cases that commented out:
59+
60+
+ Use case 1 is basic search results presented in a table.
61+
+ Use case 2 adds a filter over the Category field.
62+
+ Use case 3 adds a sort order over the Rating field.
63+
64+
Recall that the index field attributes determine which fields are searchable, filterable, sortable, facetable, and retrievable. If you want different filters and sort fields, delete and recreate the hotels index with the attribution necessary for your scenario.
65+
66+
1. Relevance tuning is a server-side operation. If you want to boost the relevance of a document based on whether the match was found in a certain field, such as "Tags", or by location, [add a scoring profile](index-add-scoring-profiles.md) to the hotel-search-index, and then rerun your queries.
67+
68+
## Next steps
69+
70+
If you want to explore client-side operations that respond to user actions, consider adding a React template to your solution:
71+
72+
> [!div class="nextstepaction"]
73+
> [C# Tutorial: Add search to a website with .NET](tutorial-csharp-overview.md)

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ Having a valid key establishes trust, on a per request basis, between the applic
118118

119119
1. In the **Browse** tab, find and then install **Azure.Search.Documents** (version 11.0 or later).
120120

121-
:::image type="content" source="media/tutorial-csharp-create-first-app/azure-search-nuget-azure.png" alt-text="Using NuGet to add Azure libraries" border="false":::
122-
123121
1. Search for the **Microsoft.Extensions.Configuration** and **Microsoft.Extensions.Configuration.Json** NuGet packages and install them as well.
124122

125123
1. Open the solution file **/v11/AzureSearchMultipleDataSources.sln**.

0 commit comments

Comments
 (0)