QdrantVectorStore preFilters causing 400 Bad Request error
#2,035 opened on Jun 24, 2025
Repository metrics
- Stars
- (3,078 stars)
- PR merge metrics
- (PR metrics pending)
Description
Describe the bug
When adding preFilters to a QdrantVectorStore query engine in LlamaIndex, Qdrant returns a "400 Bad Request" error. The error occurs when trying to filter results by projectId using the preFilters option in the asQueryEngine() method.
To Reproduce Code to reproduce the behavior:
import { qdrantClient } from "@infra/qdrant";
import { QdrantVectorStore } from "@llamaindex/qdrant";
import { VectorStoreIndex } from "llamaindex";
export async function setupSearchTool(
tenantId: string,
projectId: string,
): Promise<BaseToolWithCall> {
const vectorStore = new QdrantVectorStore({
collectionName: tenantId,
client: qdrantClient,
});
const qdrantRetriever = await VectorStoreIndex.fromVectorStore(vectorStore);
// This causes a 400 Bad Request error from Qdrant
const queryEngine = qdrantRetriever.asQueryEngine({
preFilters: {
filters: [{
key: "projectId",
operator: "==",
value: "ea8bb9be-a8c0-48f1-a60c-49339fb68570"
}]
},
});
return new QueryEngineTool({
queryEngine: queryEngine,
metadata: {
name: "rag-knowledge-base",
description: "Search tool",
},
});
}
Expected behavior
The query engine should successfully filter results by the specified projectId and return only documents that match the filter criteria. The Qdrant request should be properly formatted and not result in a 400 error.
Error Details
- Qdrant error log:
HTTP/1.1" 400 162 "-" "qdrant-js/1.14.1" 0.000596 - Application logs show: "Bad Request" errors when attempting to search the knowledge base
- Agent handoff messages indicate: "encountered technical errors accessing the knowledge base"
Desktop (please complete the following information):
- OS: macOS (darwin 24.5.0)
- JS Runtime / Framework / Bundler (select all applicable)
- Node.js
- Deno
- Bun
- Next.js
- ESBuild
- Rollup
- Webpack
- Turbopack
- Vite
- Waku
- Edge Runtime
- AWS Lambda
- Cloudflare Worker
- Others (please elaborate on this)
- Version: Node.js (version not specified, but using qdrant-js/1.14.1)
Additional context
- The issue appears to be with the
preFilterssyntax/structure when integrating LlamaIndex with Qdrant - The same code works without the
preFiltersoption - There might be a mismatch between the expected filter format by LlamaIndex and what Qdrant expects
- The commented out
asQueryToolapproach might be working, butasQueryEnginewithpreFiltersis failing - The project uses TypeScript and appears to be running in a Docker environment based on the project structure
Possible Solutions to Investigate:
- Verify the correct
preFilterssyntax for the current LlamaIndex version - Check if the filter should be structured differently (e.g., using
mustconditions or different operator syntax) - Investigate if the metadata field names in Qdrant match the filter key names
- Consider if the filter value type needs to be different (string vs UUID format)
This issue is blocking the ability to filter search results by project, which is essential for multi-tenant applications where users should only see results relevant to their specific project context.