fix(azureaisearch): preserve falsy metadata values when indexing nodes#22154
Open
citizen204 wants to merge 1 commit into
Open
fix(azureaisearch): preserve falsy metadata values when indexing nodes#22154citizen204 wants to merge 1 commit into
citizen204 wants to merge 1 commit into
Conversation
`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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_build_index_documentusedif 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 seesNonewhere 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: