Skip to content

fix(azureaisearch): preserve falsy metadata values when indexing nodes#22154

Open
citizen204 wants to merge 1 commit into
run-llama:mainfrom
citizen204:fix-21385-azure-search-falsy-metadata
Open

fix(azureaisearch): preserve falsy metadata values when indexing nodes#22154
citizen204 wants to merge 1 commit into
run-llama:mainfrom
citizen204:fix-21385-azure-search-falsy-metadata

Conversation

@citizen204

Copy link
Copy Markdown
Contributor

Summary

_build_index_document used if metadata_value: to guard the write into the index document. This discards any metadata value that is falsy — 0, "", [], False — silently replacing it with nothing (the field stays absent). On retrieval the node sees None where the original metadata held a legitimate zero or blank string.

Changing the guard to if metadata_value is not None: ensures every explicitly set value, including valid falsy ones, is written to the index.

Fixes #21385

Changes

  • llama-index-integrations/vector_stores/llama-index-vector-stores-azureaisearch/llama_index/vector_stores/azureaisearch/base.py: if metadata_value:if metadata_value is not None:

`if metadata_value:` evaluates to False for valid falsy values such as
0, empty string, or empty list, causing them to be silently dropped
instead of written to the index field. A retrieved node therefore sees
None where the original metadata held a legitimate zero or blank.

Change the guard to `if metadata_value is not None:` so all explicitly
set values are indexed.

Fixes run-llama#21385
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: falsy metadata values stored as None in Azure AI Search index

1 participant