Search code examples
azure-cognitive-search

Azure Search : Blob Metadata Field value not appearing in Indexed data


We have set Metadata on Block Blob and are able to verify the Key/Value correctly stamped on the blob. enter image description here

Out of many fields that have been defined in the index, only one field value (PromotionId) is not appearing in the indexed data, as can be confirmed by executing search through the "Search explorer". enter image description here

This field has actually been mapped to the key "ID" in the indexer. enter image description here

And has been defined in Index. enter image description here

Why is the value of this specific field not appearing in the index? Rest all metadata fields are all appearing in the index as expected.


Solution

  • The field mapping is not working because "ID" is specified as a sourceFieldName, but there is no ID property on the source Blob as it only exists on the Index you have defined.

    This may be a bit confusing since it behaves like there is an "ID" property because the "ID" field is being populated without a field mapping. However, this is because Azure Search automatically maps the "metadata_storage_path" to whichever field is the document key when no field mapping for the document key is specified. This behavior is documented here.

    If you want the PromotionId to be the document path like the ID field you can change the sourceFieldName to "metadata_storage_path" for the PromotionId field mapping. If you want to also be base64 encoded you can add the fieldMappingFunction to the field mapping as well.