Skip to content

mjpraxis/search-dotnet-getting-started

 
 

Repository files navigation

page_type description languages products
sample
Contains several projects to help you get started with Azure Cognitive Search and the .NET SDK
csharp
azure
azure-cognitive-search

Getting Started with Azure Cognitive Search using .NET

This repository includes several projects that show you how to use the Azure.Search.Documents client library in Azure SDK for .NET to create C# applications that use Azure Cognitive Search.

An earlier version of the samples that were built using the Microsoft.Azure.Search client libraries can be found in the v10 branch of this repo. To download those versions, switch the branch from master to v10, and then select Code to download or open those samples.

DotNetHowTo

This sample is a simple .NET Core console application that shows you how to:

  • Create and delete a search index
  • Upload documents
  • Search and filter documents within an index

To run this sample, open the solution in Visual Studio and modify appsettings.json to use valid values for your search service.

DotNetHowToEncryptionUsingCMK

This sample demonstrates how to create a synonym-map and an index that are encrypted with a customer-managed key in Azure Key Vault. This sample uses several services that must be set up in advance: Azure Key Vault, Azure Active Directory, and modifications to your existing search service.

The appsettings.json file provides placeholders for service information.

For detailed instructions, see How to configure customer-managed keys for data encryption in Azure Cognitive Search.

DotNetHowToSynonyms

This sample demonstrates the benefits of adding a synonym map using "before-and-after" queries:

  • Creates a search index
  • Searches for documents using terms that do not appear in the indexed documents (query returns no results)
  • Define and upload synonym rules
  • Re-run the queries. This time, query results are found due to matching synonyms in the synonym list.

To run this sample, open the solution in Visual Studio and modify app.config to use valid values for your search service.

For detailed instructions, see Example: Add synonyms for Azure Cognitive Search in C#.

DotNetHowToIndexers

This sample is a simple .NET Core console application that shows how create and run a search indexer that retrieves data from an Azure SQL database.

Before you can run this sample, you will need an Azure SQL database that contains sample data used by the indexer. You will also need to modify settings in appsettings.json.

  1. Create a new database in Azure SQL named hotels.
  2. Run the data\hotels.sql script provided in this sample against your Azure SQL database.
  3. Open the DotNetHowToIndexers.sln in Visual Studio.
  4. Update the appsettings.json with your service name, api key, and connection string to your Azure SQL database.
  5. Compile and Run the project using Visual Studio.

DotNetHowToSecurityTrimming

This sample demonstrates how to implement document-level security in Azure Search using filters. To test this application thoroughly, you will need:

  1. Search service URL
  2. Search service Admin API key
  3. Azure Active Directory Tenant ID
  4. Application registration for a multi-tenant app, where the application is registered by the tenant administrator or has admin consent.

You might need to create your own Active Directory Tenant to gain sufficient permission to fully test the code.

For more information and steps, see Security filters for trimming Azure Search results using Active Directory identities.

DotNetETagsExplainer

This sample is a .NET Core console application that shows how to use ETags to update Azure Cognitive Search resources safely in the presence of concurrency. The code in this sample simulates concurrent write operations so that you can see how that condition is handled.

To run this sample, open the solution in Visual Studio and modify appsettings.json to use valid values for your search service.

Retired samples

The following samples have been removed from the master branch.

DotNetHowToAutocomplete

This sample was not migrated to use the Azure.Search.Documents client library. It has been replaced by a project in the create-first-app sample in the azure-search-dotnet-samples repository. Alternatively, you can look at the v10 version of the sample.

DotNetHowToMultipleDataSources

This sample was not migrated to use the Azure.Search.Documents client library. It has been replaced by the multiple-data-sources sample in the azure-search-dotnet-samples repository. Alternatively, you can look at the v10 version of the sample.

DotNetSample

This sample was not migrated to use the Azure.Search.Documents client library. We recommend that you refer to DotNetHowToIndexers to view code that calls the Azure SQL Indexer. Alternatively, you can look at the v10 version of the sample.


This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

About

Getting Started with Azure Search using .NET

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%