Sunil Nagireddy, when you create a vector index in Azure AI Foundry, the schema is generated automatically and metadata fields like metadata_storage_name are not marked filterable and Foundry’s UI doesn’t let you change that. To restrict searches to a particular PDF, you need to edit the underlying Cognitive Search index schema so that there is a filterable file-name field, re-index your data, and then supply an OData filter in your vector query.
First, open your Azure Cognitive Search resource in the portal, go to Indexes, find the index that Foundry created for your PDFs, and export its JSON definition. In that JSON, add a new field called sourceFileName (or edit the existing metadata_storage_name field) so that it reads.
{
"name": "sourceFileName",
"type": "Edm.String",
"searchable": false,
"filterable": true,
"retrievable": true,
"sortable": false,
"facetable": false
}
If you prefer to reuse the built-in metadata field, simply set its "filterable": true
. Then recreate the index either by deleting the old one or giving the new one the same name using the portal or the Azure CLI.
az search index show \
--name your-index-name \
--service-name your-search-service \
--resource-group your-rg > index.json
# edit index.json as above
az search index create \
--name your-index-name \
--service-name your-search-service \
--resource-group your-rg \
--body @index.json
Once the new schema is in place, rerun your indexer or re-execute the Foundry ingestion job so that every document chunk carries the sourceFileName value. You can confirm in Search Explorer that each document now shows the correct file name.
Finally, in your Prompt Flow’s vector-search (Index Lookup) step, paste an OData filter like:
sourceFileName eq 'MyDocument.pdf'
(or metadata_storage_name eq 'MyDocument.pdf'
if you updated that field). This makes sure the search only matches embeddings from that specific PDF.
Hope it helps!
Please do not forget to click "Accept the answer” and Yes
wherever the information provided helps you, this can be beneficial to other community members.
If you have any other questions or still running into more issues, let me know in the "comments" and I would be happy to help you.