Azure / azure-search-vector-samples

A repository of code samples for Vector search capabilities in Azure AI Search.
https://azure.microsoft.com/products/search
MIT License
690 stars 285 forks source link

Add metadata field for search index in azure-search-integrated-vectorization-sample.ipynb #232

Closed sindre-bouvet closed 2 months ago

sindre-bouvet commented 2 months ago

I have some data in a storage container that I want to create a search index for. This data has a metadata field called "sourceUrl" that I want to add to the search index, such that when a file is returned, then we can fetch this information as well.

I have added a couple of lines to the notebook to accomplish this:

SearchField(name="sourceUrl", type=SearchFieldDataType.String)

in the fields-list

InputFieldMappingEntry(name="sourceUrl", source="/document/metadata_storage_sourceUrl"),

in the SearchIndexerIndexProjectionSelector()

FieldMapping(source_field_name="metadata_storage_sourceUrl", target_field_name="sourceUrl")

in the field-mappings list for the SearchIndexer.

But I am unable to populate the field sourceUrl in the indexer - it's just null.

Note: I've tried without "storage" also: metadata_sourceUrl.

I get this warning in the Indexer:

Details: Missing or empty value '/document/metadata_storage_sourceUrl'.

And I have verified that all of the files has the metadata sourceUrl: image

sindre-bouvet commented 2 months ago

For anybody experiencing the same issue: the way to reference metadata is just the name of the metadata-field, in the blobs. So instead of "metadata_sourceUrl" or "metadata_storage_sourceUrl" just use "sourceUrl".