Edit vector store fields. #15159
Unanswered
d3buggerdan
asked this question in
Q&A
Replies: 1 comment 12 replies
-
To make the Here is the updated configuration: logger.info(f"Configuring {index_name} fields for Azure AI Search")
fields = [
SimpleField(name=self._field_mapping["id"], type="Edm.String", key=True),
SearchableField(
name=self._field_mapping["chunk"],
type="Edm.String",
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=self._vector_profile_name,
),
SimpleField(name=self._field_mapping["metadata"], type="Edm.String"),
SearchableField(
name=self._field_mapping["doc_id"], type="Edm.String", filterable=True, sortable=True
),
SearchableField(
name=self._field_mapping["date"], type="Edm.String", filterable=True, sortable=True
),
SearchableField(
name=self._field_mapping["userid"], type="Edm.String", filterable=True, sortable=True
),
SearchableField(
name=self._field_mapping["contractid"], type="Edm.String", filterable=True, sortable=True
),
SearchableField(
name=self._field_mapping["title"], type="Edm.String", filterable=True, sortable=True
),
]
logger.info(f"Configuring {index_name} metadata fields")
metadata_index_fields = self._create_metadata_index_fields()
fields.extend(metadata_index_fields)
logger.info(f"Configuring {index_name} vector search")
# Configure the vector search algorithms and profiles
vector_search = VectorSearch(
algorithms=[
HnswAlgorithmConfiguration(
name="myHnsw",
kind=VectorSearchAlgorithmKind.HNSW,
parameters=HnswParameters(
m=4,
ef_construction=400,
ef_search=500,
metric=VectorSearchAlgorithmMetric.COSINE,
),
),
ExhaustiveKnnAlgorithmConfiguration(
name="myExhaustiveKnn",
kind=VectorSearchAlgorithmKind.EXHAUSTIVE_KNN,
parameters=ExhaustiveKnnParameters(
metric=VectorSearchAlgorithmMetric.COSINE,
),
),
],
profiles=[
VectorSearchProfile(
name="myHnswProfile",
algorithm_configuration_name="myHnsw",
),
VectorSearchProfile(
name="myExhaustiveKnnProfile",
algorithm_configuration_name="myExhaustiveKnn",
),
],
)
logger.info(f"Configuring {index_name} semantic search")
semantic_config = SemanticConfiguration(
name="mySemanticConfig",
prioritized_fields=SemanticPrioritizedFields(
content_fields=[SemanticField(field_name=self._field_mapping["chunk"])],
),
)
semantic_search = SemanticSearch(configurations=[semantic_config])
index = SearchIndex(
name=index_name,
fields=fields,
vector_search=vector_search,
semantic_search=semantic_search,
)
logger.debug(f"Creating {index_name} search index")
self._index_client.create_index(index) This configuration ensures that the |
Beta Was this translation helpful? Give feedback.
12 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
metadata_fields = {
"date": ("date", MetadataIndexFieldType.STRING),
"userid": ("userid", MetadataIndexFieldType.STRING),
"contractid": ("contractid", MetadataIndexFieldType.STRING),
"title": ("title", MetadataIndexFieldType.STRING)
}
Define the vector store
vector_store = AzureAISearchVectorStore(
search_or_index_client=index_client,
filterable_metadata_field_keys=metadata_fields,
index_name=index_name,
index_management=IndexManagement.CREATE_IF_NOT_EXISTS,
id_field_key="id",
chunk_field_key="chunk",
embedding_field_key="embedding",
embedding_dimensionality=1536,
metadata_string_field_key="metadata",
doc_id_field_key="doc_id",
language_analyzer="en.lucene",
vector_algorithm_type="exhaustiveKnn",
)
I want the doc_id, date, userid, contractid, and title to be sortable and searchable as well, right now they are only retrievable and filterable
@dosu
Beta Was this translation helpful? Give feedback.
All reactions