[JS] @langchain/qdrant: add a hybrid retrieval mode (parity with langchain-qdrant for Python)

@valeriocomo Welcome to the LangChain community!

Really appreciate the effort you’ve put into detailing your request. However, I’d recommend opening an issue in the official repository so the maintainers can review it and track it more effectively:

Thanks @keenborder786 for the pointer! I’ve opened the issue here:

The design discussion (a retrieval mode on the store vs. a separate hybridSearch() method, plus the other open questions) will continue there.

Thank you @valeriocomo will appreciate if you can close this thread by marking the answer as solution.

Great proposal. Bringing @langchain/qdrant to parity with Python’s langchain-qdrant (retrieval_mode: "dense" | "sparse" | "hybrid") is much cleaner now that @qdrant/js-client-rest (>= 1.10.0) exposes the unified client.query() API with native server-side Reciprocal Rank Fusion (fusion: "rrf") and Distribution-Based Score Fusion (fusion: "dbsf").

Recommended Architecture for the @langchain/qdrant PR

To keep full backward compatibility with existing single-vector JS collections while supporting hybrid search:

  1. Constructor & QdrantLibArgs Extension:
    • Add retrievalMode?: "dense" | "sparse" | "hybrid" (defaulting to "dense").
    • Add sparseEmbeddings?: SparseEmbeddingsInterface (matching (texts: string[]) => Promise<{ indices: number[]; values: number[] }[]>), plus vectorName?: string and sparseVectorName?: string (defaulting to "langchain-sparse" to match Python’s SPARSE_VECTOR_NAME).
  2. Single-Roundtrip Hybrid Query via client.query():
    Instead of issuing separate dense and sparse requests and fusing on the client, use Qdrant’s prefetch + fusion pipeline in similaritySearchVectorWithScore:
const queryResponse = await this.client.query(this.collectionName, {
  prefetch: [
    {
      query: denseEmbedding,
      using: this.vectorName,
      limit: k * 2,
      filter,
    },
    {
      query: {
        indices: sparseEmbedding.indices,
        values: sparseEmbedding.values,
      },
      using: this.sparseVectorName,
      limit: k * 2,
      filter,
    },
  ],
  query: { fusion: this.fusionType ?? "rrf" },
  limit: k,
  with_payload: true,
  with_vector: false,
});
  1. Collection Initialization (ensureCollection): When retrievalMode === "hybrid" or "sparse", pass sparse_vectors: { [this.sparseVectorName]: {} } alongside vectors in createCollection. That makes existing Python langchain-qdrant hybrid collections 100% interoperable with @langchain/qdrant in TypeScript.

thanks for your feedback!
I’ll add these details to my issue

That’s my PR. ID 12247 on langchain.js repo