Skip to content

[Bug] Sparse Index Query Not Supported with QueryOptions type #337

@harrisonlinowes

Description

@harrisonlinowes

Is this a new bug?
In other words: Is this an error, flaw, failure or fault? Please search Github issues and check our Community Forum to see if someone has already reported the bug you encountered.

If this is a request for help or troubleshooting code in your own Pinecone project, please join the Pinecone Community Forum.

  • I believe this is a new bug
  • I have searched the existing Github issues and Community Forum, and I could not find an existing post for this bug

Describe the bug
As of December of 2024 the recommended approach for hybrid search is to use cascading retrieval via a separate dense and sparse index (blog post). To implement this in typescript the SDK must support querying using only the sparseVector parameter.

Currently the query function is typed in a way that requires vector to be supplied. The QueryByVectorValues type must make vector parameter optional.

Error information
"my-sparse-index" must be a sparse index.

const index = pc.index<T>("my-sparse-index");
const res = await index.query({
  vector: [], // required to satisfy typing
  sparseVector: sparseVector.vectors[0],
  topK: 10,
});

Results in:
PineconeArgumentError: You must enter an array of `RecordValues` in order to query by vector values.

Steps to reproduce the issue locally
Include steps to reproduce the issue here. If you have sample code or a script that can be used to replicate this issue, please include that as well (including any dependent files to run the code).

See section above.

Environment

  • OS and version: Mac
  • Node version: v20.18.1
  • Typescript SDK version: "@pinecone-database/pinecone": "^5.1.1",

Additional context
Current work around:

const index = pc.index<T>("my-sparse-index");
// @ts-ignore
const res = await index.query({
  sparseVector: sparseVector.vectors[0],
  topK: 10,
});

Metadata

Metadata

Labels

bugSomething isn't workingstatus:on-roadmapThis has been picked up by the team and is on our roadmap

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions