in reference-implementations/semantic-search-for-images/src/ingestion/Services/AiSearchService.cs [28:57]
public async Task InitializeAsync()
{
var indexClient = new SearchIndexClient(new Uri(_appSettings.AiSearch.Uri), _tokenCredential);
SearchIndex index = new SearchIndex(_appSettings.AiSearch.Index)
{
Fields = {
new SimpleField("objectId", SearchFieldDataType.String) { IsKey = true, IsFilterable = true, IsSortable = true },
new SimpleField("imageUrl", SearchFieldDataType.String),
new SimpleField("artist", SearchFieldDataType.String) { IsFacetable = true, IsSortable = true },
new SearchableField("title") { IsSortable = true },
new SimpleField("creationDate", SearchFieldDataType.String) { IsSortable = true },
new SimpleField("metadata", SearchFieldDataType.String),
new VectorSearchField("imageVector", _appSettings.AiSearch.VectorSearchDimensions, _appSettings.AiSearch.VectorSearchProfile)
},
VectorSearch = new()
{
Profiles =
{
new VectorSearchProfile(_appSettings.AiSearch.VectorSearchProfile, _appSettings.AiSearch.VectorSearchHnswConfig)
},
Algorithms =
{
new HnswAlgorithmConfiguration(_appSettings.AiSearch.VectorSearchHnswConfig)
}
}
};
await indexClient.CreateOrUpdateIndexAsync(index);
}