Valid Azure Index structure for vector_store #25208
-
Checked other resources
Commit to Help
Example Codevector_store: AzureSearch = AzureSearch(
azure_search_endpoint=vector_store_address,
azure_search_key=vector_store_password,
index_name=index_name,
embedding_function=embeddings.embed_query,
) DescriptionIs there a defined field name and structrue that is accepted by vector_store langhcain while using Azure AI Index.
System InfoWindows |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 12 replies
-
Hey, @aayushrajj! 👋 I'm here to help you with your bug, answer your questions, and maybe even inspire you to become a contributor! Yes, there are defined field names and structures accepted by
These fields can be overridden using environment variables Here is the relevant code snippet: # Allow overriding field names for Azure Search
FIELDS_ID = get_from_env(
key="AZURESEARCH_FIELDS_ID", env_key="AZURESEARCH_FIELDS_ID", default="id"
)
FIELDS_CONTENT = get_from_env(
key="AZURESEARCH_FIELDS_CONTENT",
env_key="AZURESEARCH_FIELDS_CONTENT",
default="content",
)
FIELDS_CONTENT_VECTOR = get_from_env(
key="AZURESEARCH_FIELDS_CONTENT_VECTOR",
env_key="AZURESEARCH_FIELDS_CONTENT_VECTOR",
default="content_vector",
)
FIELDS_METADATA = get_from_env(
key="AZURESEARCH_FIELDS_TAG", env_key="AZURESEARCH_FIELDS_TAG", default="metadata"
) The default fields structure is defined as follows: default_fields = [
SimpleField(
name=FIELDS_ID,
type=SearchFieldDataType.String,
key=True,
filterable=True,
),
SearchableField(
name=FIELDS_CONTENT,
type=SearchFieldDataType.String,
),
SearchField(
name=FIELDS_CONTENT_VECTOR,
type=SearchFieldDataType.Collection(SearchFieldDataType.Single),
searchable=True,
vector_search_dimensions=vector_search_dimensions
or len(self.embed_query("Text")),
vector_search_profile_name="myHnswProfile",
),
SearchableField(
name=FIELDS_METADATA,
type=SearchFieldDataType.String,
),
] You should adjust your structure to match these field names and types [1]. |
Beta Was this translation helpful? Give feedback.
Hey, @aayushrajj! 👋 I'm here to help you with your bug, answer your questions, and maybe even inspire you to become a contributor!
Yes, there are defined field names and structures accepted by
vector_store
in LangChain while using Azure AI Index. The fields are:FIELDS_ID
: Default is "id"FIELDS_CONTENT
: Default is "content"FIELDS_CONTENT_VECTOR
: Default is "content_vector"FIELDS_METADATA
: Default is "metadata"These fields can be overridden using environment variables
AZURESEARCH_FIELDS_ID
,AZURESEARCH_FIELDS_CONTENT
,AZURESEARCH_FIELDS_CONTENT_VECTOR
, andAZURESEARCH_FIELDS_TAG
respectively.Here is the relevant code snippet: