Skip to content
Snippets Groups Projects
Unverified Commit f4bcb31f authored by ryanrib14's avatar ryanrib14 Committed by GitHub
Browse files

fix the bug on vector_search_profile default(this profile did not exist) and...

fix the bug on vector_search_profile default(this profile did not exist) and add the possibility to choose language_analyzer of searchable fields, now on v0.10.3 format (#10675)
parent bf0b0c57
No related branches found
No related tags found
No related merge requests found
......@@ -143,14 +143,14 @@ class AzureAISearchVectorStore(VectorStore):
SearchableField(
name=self._field_mapping["chunk"],
type="Edm.String",
analyzer_name="en.microsoft",
analyzer_name=self.language_analyzer,
),
SearchField(
name=self._field_mapping["embedding"],
type=SearchFieldDataType.Collection(SearchFieldDataType.Single),
searchable=True,
vector_search_dimensions=self.embedding_dimensionality,
vector_search_profile_name="default",
vector_search_profile_name=self.vector_profile_name,
),
SimpleField(name=self._field_mapping["metadata"], type="Edm.String"),
SimpleField(
......@@ -243,6 +243,10 @@ class AzureAISearchVectorStore(VectorStore):
] = None,
index_management: IndexManagement = IndexManagement.NO_VALIDATION,
embedding_dimensionality: int = 1536,
vector_algorithm_type: str = "exhaustiveKnn",
# If we have content in other languages, it is better to enable the language analyzer to be adjusted in searchable fields.
# https://learn.microsoft.com/en-us/azure/search/index-add-language-analyzers
language_analyzer: str = "en.lucene",
**kwargs: Any,
) -> None:
# ruff: noqa: E501
......@@ -306,6 +310,16 @@ class AzureAISearchVectorStore(VectorStore):
self._search_client: SearchClient = cast(SearchClient, None)
self.embedding_dimensionality = embedding_dimensionality
if vector_algorithm_type == "exhaustiveKnn":
self.vector_profile_name = "myExhaustiveKnnProfile"
elif vector_algorithm_type == "hnsw":
self.vector_profile_name = "myHnswProfile"
else:
raise ValueError(
"Only 'exhaustiveKnn' and 'hnsw' are supported for vector_algorithm_type"
)
self.language_analyzer = language_analyzer
# Validate search_or_index_client
if search_or_index_client is not None:
if isinstance(search_or_index_client, SearchIndexClient):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment