Skip to content

fix(vector_store): normalize QdrantStore.search_vectors() to return "metadata" - #841

Merged
KaifAhmad1 merged 3 commits into
semantica-agi:mainfrom
divyankshah:fix/gh-840-qdrant-metadata-key
Aug 6, 2026
Merged

KaifAhmad1 merged 3 commits into
semantica-agi:mainfrom
divyankshah:fix/gh-840-qdrant-metadata-key

Conversation

@divyankshah

@divyankshah divyankshah commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • QdrantStore.search_vectors() returned results keyed by "payload", while HybridSearch and PineconeStore both use "metadata". This silently dropped metadata from Qdrant results and caused HybridSearch.filter_by_metadata() to reject every candidate when a filter was applied (empty result sets).
  • Normalized QdrantCollection.search_points() to return "metadata" instead of "payload", matching the convention already used by PineconeStore.search_vectors().

Fixes #840

Test plan

  • Extended tests/vector_store/test_vector_store_deepdive.py::test_qdrant_store to assert Qdrant search results expose "metadata" (not "payload") and that HybridSearch.filter_by_metadata() matches against them correctly.
  • pytest tests/vector_store/ — 141 passed, 61 skipped, same 6 pre-existing test_pinecone_store.py failures as on unmodified main (unrelated mocking issue, verified via git stash).

Copilot AI lite review requested due to automatic review settings August 6, 2026 00:21
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Fix QdrantStore search results to expose metadata (not payload)

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Align Qdrant search result key with other stores by returning "metadata".
• Prevent HybridSearch metadata filtering from rejecting all Qdrant candidates.
• Extend Qdrant store tests to assert metadata exposure and filter compatibility.
Diagram

graph TD
  A["QdrantStore.search_vectors"] --> B["QdrantSearch.similarity_search"] --> C["QdrantCollection.search_points"] --> D{{"Qdrant client.search"}} --> E["Results: id/score/metadata"] --> F["HybridSearch.filter_by_metadata"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Map payload→metadata in QdrantStore.search_vectors only
  • ➕ Keeps lower-level QdrantCollection wrapper closer to Qdrant terminology
  • ➕ Localizes the API normalization at the public store boundary
  • ➖ Leaves an inconsistent internal result shape that can leak to other call sites
  • ➖ Harder to ensure all downstream consumers see the same key
2. Make HybridSearch accept both metadata and payload keys
  • ➕ Backward-compatible with any existing callers relying on payload
  • ➕ More tolerant of heterogeneous result shapes from different stores
  • ➖ Bakes store-specific quirks into shared search logic
  • ➖ Can mask future integration bugs instead of enforcing a canonical contract

Recommendation: The chosen approach (normalizing Qdrant results to the canonical "metadata" key at the QdrantCollection mapping layer) is the best default because it enforces a consistent contract across vector stores and keeps HybridSearch/store-agnostic logic simple. If "payload" was previously treated as part of the public QdrantStore result contract, consider a short deprecation window (e.g., temporarily returning both keys) to reduce downstream breakage.

Files changed (2) +11 / -1

Bug fix (1) +1 / -1
qdrant_store.pyNormalize Qdrant search hits to return metadata key +1/-1

Normalize Qdrant search hits to return metadata key

• Updates QdrantCollection.search_points() to emit search results with a "metadata" field instead of "payload". This aligns QdrantStore behavior with the convention used by HybridSearch and other vector stores.

semantica/vector_store/qdrant_store.py

Tests (1) +10 / -0
test_vector_store_deepdive.pyAdd regression assertions for Qdrant metadata and HybridSearch filtering +10/-0

Add regression assertions for Qdrant metadata and HybridSearch filtering

• Extends the Qdrant store deep-dive test to assert results include "metadata" (and not "payload"). Adds a regression check that HybridSearch.filter_by_metadata() successfully matches Qdrant results when a metadata filter is applied.

tests/vector_store/test_vector_store_deepdive.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Qdrant vector search result normalization by aligning Qdrant’s returned metadata key with the rest of the vector store ecosystem (HybridSearch / PineconeStore), preventing metadata from being silently dropped and ensuring metadata filtering works correctly.

Changes:

  • Updated QdrantCollection.search_points() to return result metadata under the "metadata" key (instead of "payload").
  • Extended Qdrant store deep-dive tests to assert the normalized shape and to verify HybridSearch.filter_by_metadata() matches against Qdrant results.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
semantica/vector_store/qdrant_store.py Normalizes Qdrant search result dictionaries to expose "metadata" instead of "payload".
tests/vector_store/test_vector_store_deepdive.py Adds assertions ensuring Qdrant results expose "metadata" and validates hybrid metadata filtering behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

…metadata"

QdrantStore.search_vectors() returned results keyed by "payload" while
HybridSearch and PineconeStore both expect/return "metadata". This silently
dropped metadata from Qdrant results and caused HybridSearch.filter_by_metadata
to reject every candidate when a filter was applied (empty result sets).

Fixes semantica-agi#840
Copilot AI review requested due to automatic review settings August 6, 2026 11:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

Adds an Unreleased/Fixed entry for semantica-agi#841 (closes semantica-agi#840) — QdrantStore
search results were keyed "payload" instead of "metadata", breaking
HybridSearch.filter_by_metadata() for Qdrant results.
Copilot AI review requested due to automatic review settings August 6, 2026 13:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@KaifAhmad1 KaifAhmad1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified end-to-end:

  • Diff is a single-line rename in QdrantCollection.search_points() (qdrant_store.py:168), "payload" → "metadata".
  • Traced the full call chain (QdrantStore.search_vectors() → QdrantSearch.similarity_search() → QdrantCollection.search_points()) — no intermediate re-keying, so this one line is the sole source of the bug and the fix is complete, not partial.
  • Confirmed PineconeStore.search_vectors() already returns "metadata", so this genuinely aligns Qdrant with the existing convention rather than introducing a new one.
  • Grepped the repo for any consumer reading result["payload"] off vector-store search output — none found, so the rename breaks nothing downstream.
  • Ran pytest tests/vector_store/: 167 passed, 36 skipped, same 6 pre-existing test_pinecone_store.py failures reproduced independently on unmodified main (unrelated mocking issue, confirmed via direct branch comparison, not just git stash).
  • New test (test_qdrant_store) directly asserts the key rename and exercises HybridSearch.filter_by_metadata() against real Qdrant-shaped results — matches the actual bug path from #840, not just the surface rename.

Minor non-blocking note: the module docstring and insert_vectors()'s payloads param still use Qdrant's native "payload" terminology for the storage side — fine to leave, since this PR is scoped to the search result key other modules consume.

Approving.

@KaifAhmad1
KaifAhmad1 merged commit 3e5d267 into semantica-agi:main Aug 6, 2026
10 checks passed
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.

HybridSearch drops Qdrant metadata because backend payload is not normalized

3 participants