An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
Hey there Thibault Verlinde
Thats a good question thanks for using QandA platform
So i guess you need to define and configure the vectorizer within the SearchIndex object before creating the index.
Lemme modify your code to include a vectorizer, below
var indexName = _srchClient.IndexName;
var vectorSearchConfigName = "vectorconfig-" + _options.ProjectName;
var vectorSearchProfileName = "vectorprofile-" + _options.ProjectName;
var vectorizer = new SearchIndexVectorizer
{
Name = vectorSearchConfigName,
Source = "/document/content", // Specify the source field for vectorization
Tokenizer = new LexicalTokenizer(LexicalTokenizerName.StandardLucene),
OdataType = "#Microsoft.Azure.Search.StandardAnalyzer"
};
var index = new SearchIndex(indexName)
{
VectorSearch = new()
{
Algorithms =
{
new HnswAlgorithmConfiguration(vectorSearchConfigName)
},
Profiles =
{
new VectorSearchProfile(vectorSearchProfileName, vectorSearchConfigName)
}
},
Fields =
{
new SimpleField("id", SearchFieldDataType.String) { IsKey = true },
new SearchableField("content") { AnalyzerName = LexicalAnalyzerName.StandardLucene },
new SimpleField("sourcePage", SearchFieldDataType.String) {IsFacetable = true},
new SimpleField("sourceFile", SearchFieldDataType.String) {IsFacetable = true},
new SearchField("embedding", SearchFieldDataType.Collection(SearchFieldDataType.Single))
{
VectorSearchDimensions = 1536,
IsSearchable = true,
VectorSearchProfileName = vectorSearchProfileName
}
},
Vectorizers = { vectorizer } // Add the vectorizer to the index
};
// Now ccreate a new search index
await _srchIndexClient.CreateIndexAsync(index);
If this helps kindly accept the answer thanks much.