Following-up from the comments, to benefit the community, summarizing the answer shared by Ho, Keith D.
Scenario:
Working on Setting up an Azure Search Service Index that includes both a Semantic Configuration and a Vector Profile. Although you have successfully created the index with the Semantic Configuration, the Vector Profile is not appearing as expected.
Question:
How can you ensure that a Vector Profile is correctly created and included in your Azure Search Service Index using the provided code?
Code:
azure-search-documents==11.4.0a20230509004
from azure.core.credentials import AzureKeyCredential
from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents.indexes.models import (
PrioritizedFields,
SearchIndex,
SearchField,
SearchFieldDataType,
SearchIndex,
SemanticConfiguration,
SemanticField,
SearchField,
SemanticSettings,
VectorSearch,
VectorSearchAlgorithmConfiguration,
)
from dotenv import load_dotenv
import os
def create_index(index_name):
load_dotenv()
# create azure search index
client = SearchIndexClient(endpoint=os.getenv("endpoint"), credential=AzureKeyCredential(os.getenv("AZURE_SEARCH_ADMIN_KEY")))
fields=[
SearchField(name="id", type=SearchFieldDataType.String, key=True),
SearchField(name="title", type=SearchFieldDataType.String, searchable=True, analyzer_name="standard.lucene"),
SearchField(name="tag", type=SearchFieldDataType.String, searchable=True, analyzer_name="standard.lucene"),
SearchField(name="metadata", type=SearchFieldDataType.String, searchable=True, analyzer_name="standard.lucene"),
SearchField(name="content", type=SearchFieldDataType.String, searchable=True, analyzer_name="standard.lucene"),
SearchField(name="content_vector", type=SearchFieldDataType.Collection(SearchFieldDataType.Single), searchable=True, dimensions=1536, vector_search_configuration="default"),
]
vector_search = VectorSearch(
algorithm_configurations=[
VectorSearchAlgorithmConfiguration(
name="default",
kind="hnsw",
hnsw_parameters={
"m": 4,
"efConstruction": 400,
"efSearch": 500,
"metric": "cosine"
}
)
]
)
semantic_settings = SemanticSettings(
configurations=[SemanticConfiguration(
name="semantic_configuration_name",
prioritized_fields=PrioritizedFields(
title_field=SemanticField(field_name="title"),
prioritized_keywords_fields=[
SemanticField(field_name="tag")],
prioritized_content_fields=[
SemanticField(field_name="content")]
)
)
]
)
# Create the search index with the semantic settings and vector search
index = SearchIndex(name=index_name, fields=fields, vector_search=vector_search, semantic_settings=semantic_settings)
client.create_index(index)
Answer shared by Ho, Keith D.
Resolution:
Following the tutorial and sample worked: Vector search in Python (Azure AI Search)
--The notebook demonstrates how to use Azure Cognitive Search for vector search with Python. It covers the basic setup, indexing, and querying of vector data. The document demonstrates a basic vector search workflow using Azure AI Search with a sample.
> please click Accept Answer - it will benefit the community/users to find the answer quickly.