Table of Contents

Interface IAzureAISearchService

Namespace
FoundationaLLM.Common.Interfaces
Assembly
FoundationaLLM.Common.dll

Interface for Azure AI Search Service.

public interface IAzureAISearchService
Extension Methods

Methods

CreateIndexIfNotExists(string, IEnumerable<SearchField>, VectorSearch?)

Creates an index in the Azure AI Search service if it does not already exist.

Task CreateIndexIfNotExists(string indexName, IEnumerable<SearchField> indexFields, VectorSearch? indexConfiguration = null)

Parameters

indexName string

The name of the index to create.

indexFields IEnumerable<SearchField>

The list of fields for the newly created index.

indexConfiguration VectorSearch

The optionsl vectorization configuration for the newly created index.

Returns

Task

DeleteDocuments(string, string, string)

Deletes documents from the specified index in the Azure AI Search service based on a filter.

Task<int> DeleteDocuments(string indexName, string keyFieldName, string filter)

Parameters

indexName string

The name of the index from which the documents should be deleted.

keyFieldName string

The name of the key field for the index.

filter string

The filter used to identify the documents to be deleted.

Returns

Task<int>

The number of documents that were deleted.

SearchDocuments(string, IEnumerable<string>, string, string?, ReadOnlyMemory<float>, string, float, int, bool)

Searches for documents in the specified index that match the given filter and are similar to the provided user prompt embedding.

Task<IEnumerable<SearchDocument>> SearchDocuments(string indexName, IEnumerable<string> select, string filter, string? userPrompt, ReadOnlyMemory<float> userPromptEmbedding, string embeddingPropertyName, float similarityThreshold, int topN, bool useSemanticRanking)

Parameters

indexName string

The name of the index to search within.

select IEnumerable<string>

A list of fields to select in the search results. If null or empty, all fields will be selected.

filter string

A filter expression to narrow down the search results.

userPrompt string

The original user prompt.

userPromptEmbedding ReadOnlyMemory<float>

A read-only memory segment representing the embedding of the user prompt.

embeddingPropertyName string

The name of the index property that contains embeddings.

similarityThreshold float

The minimum similarity score required for a document to be included in the results. Must be a value between 0 and 1.

topN int

The maximum number of documents to return. Must be a positive integer.

useSemanticRanking bool

A flag that indicates whether semantic ranking should be used or not.

Returns

Task<IEnumerable<SearchDocument>>

An enumerable collection of SearchDocument objects that match the filter and meet the similarity threshold, ordered by relevance. The collection will be empty if no matching documents are found.

UploadDocuments(string, List<string>, List<object[]>)

Uploads documents to the specified index in the Azure AI Search service.

Task UploadDocuments(string indexName, List<string> fieldNames, List<object[]> fieldValues)

Parameters

indexName string

The name of the index in which the documents should be uploaded.

fieldNames List<string>

The names of the fields of the documents.

fieldValues List<object[]>

The values of the fields of the documents.

Returns

Task