Populating custom fields when indexing documents in an Azure AI Search index #28766
Replies: 1 comment 2 replies
-
To ensure that the values in your metadata dictionary are correctly populated in the "title", "source", and "page_number" fields in your Azure AI Search index, you need to make sure that the metadata fields are mapped correctly when adding documents to the index. Here’s how you can do it:
texts = ["Document content 3", "Document content 4"]
metadatas = [
{ "title": "Title 1", "source": "Source A", "page_number": "1"},
{ "title": "Title 2", "source": "Source B", "page_number": "2"},
]
# Add texts with metadata to the index
for text, metadata in zip(texts, metadatas):
document = {
"content": text,
"title": metadata["title"],
"source": metadata["source"],
"page_number": metadata["page_number"]
}
vector_store.add_document(document)
By ensuring that each field in the metadata is directly mapped to the corresponding field in the index schema, you should be able to populate the "title", "source", and "page_number" fields correctly. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Beta Was this translation helpful? Give feedback.
-
I have an Azure AI index defined with the following schema:
I run the following indexing script to add sample docs to my index:
However, when I check the documents in my Azure index I see that the field
title
,``source,and
page_number` are all null:How do I index my documents such as the values in the metadata dictionary I provide to the method are passed to my "title", "source", and "page_number" fields defined in my index' schema?
Beta Was this translation helpful? Give feedback.
All reactions