Enigmatry.Entry.AzureSearch 9.1.1-preview.5

This is a prerelease version of Enigmatry.Entry.AzureSearch.
dotnet add package Enigmatry.Entry.AzureSearch --version 9.1.1-preview.5
                    
NuGet\Install-Package Enigmatry.Entry.AzureSearch -Version 9.1.1-preview.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Enigmatry.Entry.AzureSearch" Version="9.1.1-preview.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Enigmatry.Entry.AzureSearch" Version="9.1.1-preview.5" />
                    
Directory.Packages.props
<PackageReference Include="Enigmatry.Entry.AzureSearch" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Enigmatry.Entry.AzureSearch --version 9.1.1-preview.5
                    
#r "nuget: Enigmatry.Entry.AzureSearch, 9.1.1-preview.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Enigmatry.Entry.AzureSearch@9.1.1-preview.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Enigmatry.Entry.AzureSearch&version=9.1.1-preview.5&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Enigmatry.Entry.AzureSearch&version=9.1.1-preview.5&prerelease
                    
Install as a Cake Tool

Azure Search Integration

A library that provides integration with Azure Cognitive Search, enabling full-text search capabilities in your applications.

Intended Usage

Use this library when you need to implement advanced search functionality using Azure Cognitive Search, including indexing, searching, filtering, faceting, and suggestions.

Installation

Add the package to your project:

dotnet add package Enigmatry.Entry.AzureSearch

Usage Example

Configuring a searchable model:

using Azure.Search.Documents.Indexes;
using Azure.Search.Documents.Indexes.Models;

// Define a searchable model
public class ProductSearchModel
{
    [SimpleField(IsKey = true)]
    public string Id { get; set; } = string.Empty;
    
    [SearchableField(IsSortable = true)]
    public string Name { get; set; } = string.Empty;
    
    [SearchableField]
    public string Description { get; set; } = string.Empty;
    
    [SimpleField(IsSortable = true, IsFacetable = true, IsFilterable = true)]
    public decimal Price { get; set; }
    
    [SimpleField(IsFacetable = true, IsFilterable = true)]
    public string Category { get; set; } = string.Empty;
    
    [SimpleField(IsFilterable = true)]
    public bool IsAvailable { get; set; }
}

Using the search service:

using System.Threading.Tasks;
using System.Collections.Generic;
using Azure.Search.Documents.Models;
using Enigmatry.Entry.AzureSearch;
using Enigmatry.Entry.AzureSearch.Abstractions;

public class ProductSearchService
{
    private readonly ISearchService<ProductSearchModel> _searchService;
    
    public ProductSearchService(ISearchService<ProductSearchModel> searchService)
    {
        _searchService = searchService;
    }
    
    public async Task UpdateProductAsync(ProductSearchModel product)
    {
        // Add/Update a single document to the index
        await _searchService.UpdateDocument(product);
    }
    
    public async Task UpdateProductsAsync(IEnumerable<ProductSearchModel> products)
    {
        // Add/Update multiple documents to the index
        await _searchService.UpdateDocuments(products);
    }
    
    public async Task<SearchResponse<ProductSearchModel>> SearchProductsAsync(string searchText)
    {
        // Create search options using the Azure SDK
        var options = new Azure.Search.Documents.SearchOptions
        {
            Filter = "IsAvailable eq true",
            OrderBy = { "Price asc" },
            IncludeFacets = true,
            Facets = { "Category" },
            Size = 10
        };
        
        // Use SearchText to properly format and escape search terms
        var formattedSearchText = SearchText.AsEscaped(searchText);
        
        // Execute the search and get results
        return await _searchService.Search(formattedSearchText, options);
    }
    
    public async Task<SearchResponse<ProductSearchModel>> SearchProductsWithPhraseAsync(string searchText)
    {
        // Use phrase search for exact matching (wrapped in quotes)
        var phraseSearchText = SearchText.AsPhraseSearch(searchText);
        
        return await _searchService.Search(phraseSearchText);
    }
}

Configuration Example

{
  "SearchSettings": {
    "SearchServiceEndPoint": "https://myapp-search.search.windows.net",
    "ApiKey": "your-azure-search-api-key"
  }
}

Dependency Injection Example

using Enigmatry.Entry.AzureSearch.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;

public class Startup
{
    public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
    {
        // Add Azure Search core services
        services.AddAzureSearch(configuration.GetSection("SearchSettings"))
            // Register a document type with a specific index name
            .AddDocument<ProductSearchModel>("products");
            
        // Alternatively, configure settings in code
        // services.AddAzureSearch(options => {
        //     options.SearchServiceEndPoint = new Uri("https://myapp-search.search.windows.net");
        //     options.ApiKey = "your-azure-search-api-key";
        // }).AddDocument<ProductSearchModel>();
    }
}
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.1.1-preview.5 172 8/8/2025
9.1.1-preview.4 92 6/27/2025
9.1.1-preview.3 126 6/4/2025
9.1.0 155 6/3/2025
9.0.1-preview.8 126 5/26/2025
9.0.1-preview.7 216 5/13/2025
9.0.1-preview.6 102 5/9/2025
9.0.1-preview.5 129 5/7/2025
9.0.1-preview.4 126 4/30/2025
9.0.1-preview.2 133 4/1/2025
9.0.0 132 2/26/2025
8.1.1-preview.3 131 5/7/2025
8.1.1-preview.1 139 4/1/2025
8.1.0 130 2/19/2025
8.0.1-preview.4 77 2/7/2025
8.0.1-preview.2 60 1/15/2025
8.0.0 124 11/27/2024
3.4.6-preview.10 72 11/27/2024
3.4.3 133 10/22/2024
3.4.2 134 10/11/2024
3.4.1 129 10/9/2024
3.4.0 126 10/9/2024
3.3.2 134 8/28/2024
3.3.2-preview.7 78 8/27/2024
3.3.1 131 7/16/2024
3.3.1-preview.4 75 7/12/2024
3.3.0 144 6/20/2024
3.2.1-preview.4 71 6/17/2024
3.2.1-preview.1 80 5/23/2024
3.2.0 182 4/3/2024
3.1.1-preview.1 79 3/13/2024
3.1.0 155 3/8/2024
3.1.0-preview.2 87 2/19/2024
3.0.1-preview.2 95 2/9/2024
3.0.1-preview.1 92 1/24/2024
3.0.0 200 1/15/2024
3.0.0-preview.14 89 1/9/2024
3.0.0-preview.12 84 1/9/2024
3.0.0-preview.5 76 1/10/2024
3.0.0-preview.2 114 12/28/2023
3.0.0-preview 143 12/20/2023
2.1.0 187 12/28/2023
2.0.1-preview.3 117 12/1/2023
2.0.1-preview.2 96 11/29/2023
2.0.1-preview.1 87 11/28/2023
2.0.0 211 11/8/2023
2.0.0-preview.3 113 10/27/2023
2.0.0-preview.2 90 10/27/2023
2.0.0-preview.1 99 10/27/2023
2.0.0-preview 135 10/27/2023
1.1.500 173 10/27/2023
1.1.495 179 9/24/2023