Skip to content

Conversation

Sathyanarayanan-ops
Copy link

Fix: Correct FalkorDB distance strategy handling and typo

What

This PR addresses multiple issues in the FalkorDB integration:

Minor typo & formatting

Corrected EULIDEAN_DISTANCE → EUCLIDEAN_DISTANCE in the distance_strategy validation error message.

Fixed minor formatting issues with quotation marks and backticks for consistency.

Bug fixes in falkordb-langchain distance strategy handling

  • create_new_index_on_relationship() now passes self._distance_strategy
    instead of always defaulting to Euclidean, so relationship indexes
    are created with the caller’s chosen metric.
  • Added distance_strategy parameter to __from (from_documents /
    from_texts) and forward it when constructing a FalkorDBVector,
    ensuring the configured metric is respected throughout.
  • Updated similarity_search_with_score_by_vector() to use either
    vec.cosineDistance or vec.euclideanDistance depending on
    self._distance_strategy when performing metadata-filtered searches.

Tests

Added unittests to verify correct metric selection across index creation and search.

Why

Previously, FalkorDB integrations always defaulted to Euclidean distance, regardless of the user-specified distance_strategy. This caused incorrect behavior in scenarios where cosine similarity was intended.

Added coverage via unittests.

These changes fix incorrect metric assumptions and make distance selection
consistent across index creation and search.

@Sathyanarayanan-ops Sathyanarayanan-ops changed the title Fixes langchain-ai/langchain#33081 Fixes langchain-ai/langchain#33081 - FalkorDB package uses only Euclidean even if Cosine distance is specified Oct 6, 2025
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