You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating metadata fields for AzureAiSearchVectorStore using MetadataIndexFieldType.INT32, the following code evaluates a 0 as false and stores 0 as null instead of keeping the original integer in base.py:
def _default_index_mapping(
self, enriched_doc: Dict[str, str], metadata: Dict[str, Any]
) -> Dict[str, str]:
index_doc: Dict[str, str] = {}
for field in self._field_mapping:
index_doc[self._field_mapping[field]] = enriched_doc[field]
for metadata_field_name, (
index_field_name,
_,
) in self._metadata_to_index_field_map.items():
metadata_value = metadata.get(metadata_field_name)
# ERROR IS HERE
if metadata_value: --> Should be: if metadata_value is not None:
index_doc[index_field_name] = metadata_value
return index_doc
Version
0.12.12
Steps to Reproduce
Try to store any metadata field equal to 0 using AzureAISearchVectorStore as vector store
Relevant Logs/Tracbacks
The text was updated successfully, but these errors were encountered:
@QuentinMahieu Hello there! I'm here to help you with any bugs or questions you have. Let's tackle this together.
The issue you're encountering is due to the conditional check if metadata_value: in the _default_index_mapping function. This check evaluates to False for any value that is considered "falsy" in Python, including 0. As a result, metadata fields with a value of 0 are being stored as null.
To fix this, you should modify the condition to explicitly check for None instead of using a general truthiness check. Change the line:
ifmetadata_value:
to:
ifmetadata_valueisnotNone:
This change will ensure that 0 is correctly stored as an integer value rather than being converted to null[1].
QuentinMahieu
changed the title
[Bug]: Metadata fields with value 0 being stored as null in Azure AI Search
[Bug]: Metadata fields with value 0 being stored as null in Azure AI Search index
Mar 3, 2025
Bug Description
When creating metadata fields for AzureAiSearchVectorStore using MetadataIndexFieldType.INT32, the following code evaluates a 0 as false and stores 0 as null instead of keeping the original integer in base.py:
Version
0.12.12
Steps to Reproduce
Try to store any metadata field equal to 0 using AzureAISearchVectorStore as vector store
Relevant Logs/Tracbacks
The text was updated successfully, but these errors were encountered: