Skip to content

Conversation

@davide-evangelisti-prom

Summary

This PR fixes bugs in the AzureCosmosDBNoSqlVectorSearch class where the text field alias is hardcoded as "description" instead of using the dynamically configured field name from self._vector_search_fields["text_field"].

Problem

When performing vector or hybrid searches without custom projection mapping, the code has two inconsistencies:

  1. Line 900 (_generate_projection_fields method): The SQL projection hardcodes the alias as description:

    projection = f"{table}.id, {table}[@textKey] as description, ..."
  2. Line 1007 (_execute_query method): The fallback when projection_mapping is not provided uses the hardcoded string "description" instead of the configured field name:

    text_key = "description"

This causes a mismatch between:

  • The configured text field name in vector_search_fields["text_field"]
  • The actual alias used in SQL queries
  • The field name used to extract data from query results

Impact

  • Potential KeyError at runtime when the configured text field name differs from "description"
  • Inconsistent behavior between different search types (full-text search works correctly)

Changes

  1. Updated line 900 to use the dynamic field name as alias
  2. Updated line 1007 to use self._vector_search_fields["text_field"] instead of hardcoded "description"

@davide-evangelisti-prom
Copy link
Author

Hi @nagkumar91 ,
Sorry if you’re not the right person to ask — if so, feel free to point me in the right direction.
Whenever possible, could someone take a look at this PR?
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant