Azure Cognitive Search - Spell Checker Implementation in C#

sachin sipl 0 Reputation points
2023-09-28T14:28:44.4133333+00:00

I am looking for implementing spell checker for the azure cognitive search in C#. For now I have reviewed the spell checker link from the official Microsoft documentation:

https://learn.microsoft.com/en-us/azure/search/speller-how-to-add

But there's no code snippet or example that demonstrates the use in C#. The link does say we need to pass the parameters like "speller=lexicon" and "queryLanguage=en-us" with the search API call.

I have a basic search implemented for Azure Cognitive search. Please refer the below code snippet:

// Configures the 'SearchParameters' object
        SearchParameters searchParams = new SearchParameters
        {
            Skip = (page - 1) * PAGE_SIZE,
            Top = PAGE_SIZE,
            IncludeTotalResultCount = true,
            Facets = Facets
        };

        // Returns all results on initial page load
        string searchString = "*";
        if (!string.IsNullOrEmpty(searchText))
            searchString = searchText;

        // Performs a search request on the specified Azure Search index with the configured 'SearchParameters' object
        DocumentSearchResult<Document> result = searchIndexClient.Documents.Search(searchString, searchParams);

But the "SearchParameters" have no properties of passing the "speller" and "queryLanguage" parameters to get the result for spell checker. Please review the screenshot below:

User's image

Can anyone suggest for the "spell checker" for code implementation in C#?

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
994 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,553 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,913 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 17,886 Reputation points
    2023-10-06T20:37:01.7633333+00:00

    Hi @sachin sipl my apologies for the late response. I have been out of the office for the past few days. The ACS team said since this feature [Spell Checker] is still in preview, it is only available through the Azure portal and REST API only as per: Add spell check to queries - Azure Cognitive Search | Microsoft Learn. You would have to call directly the API vs using a specific language call in order to implement it as of right now.

    Hope that helps. Please let us know if you have further questions.

    Thanks!

    Grace

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.