Skip to content

Error: Vector queries can fetch at most 256 results, requested 1024. #2

@apostolisCodpal

Description

@apostolisCodpal

"convex": "^1.23.0"
"@convex-dev/mastra": "0.0.1-alpha.8"
"@mastra/core": "^0.8.3"
"@mastra/memory": "^0.2.10"

When using semantic search (in my test I used OpenAI embedding) I observe the following error:

[CONVEX M(vector/vector:createIndex)] [LOG] 'Creating index memory_messages with dimensions 1536'
[CONVEX A(vector/vector:search)] Uncaught Error: Vector queries can fetch at most 256 results, requested 1024.
    at async handler (../../node_modules/.pnpm/@[email protected]_@[email protected]_react...)

I believe the issue is coming from the following section in "@convex-dev/mastra":

// src/component/vector/vector.ts
171    const results = await ctx.vectorSearch(index.tableName, "vector", {
172      vector: queryVector,
173      limit: Math.max(topK * 10 * Object.keys(filter ?? {}).length, 1024),
174      filter: filter
175        ? (q) => {
176            return q.eq("indexName", index.indexName);
177          }
178        : undefined,
179    });

I won't pretend to understand the calculation being done for the limit field, but the convex docs clearly say that limit must be between 1 and 256 inclusive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions