Skip to content

Feature Request: Add Filtered Search Support to LSMVectorIndex #3071

@tae898

Description

@tae898

Feature Request: Add Filtered Search Support to LSMVectorIndex

Description

The LSMVectorIndex class currently uses Bits.ALL (no filter) for all vector searches. This prevents users from efficiently restricting the search space to a specific subset of records (e.g., filtering by user ID or category) during the graph traversal.

While JVector supports passing a Bits object to filter nodes during the search, this capability is not exposed in the LSMVectorIndex API.

Proposed Change

Add a new method to LSMVectorIndex that accepts a Set<RID> (or a generic filter) and maps it to a JVector Bits implementation.

public List<Pair<RID, Float>> findNeighborsFromVector(float[] queryVector, int k, Set<RID> allowedRIDs);

Implementation Details

The implementation should:

  1. Accept a Set<RID> of allowed records.
  2. Create a custom Bits implementation that checks if a node's RID is contained in the allowed set.
  3. Pass this Bits filter to GraphSearcher.search(...) instead of Bits.ALL.

Example Usage (Java)

LSMVectorIndex index = ...;
float[] vector = ...;
Set<RID> allowed = Set.of(new RID(10, 0), new RID(10, 1));

// Perform search restricted to only the RIDs in 'allowed'
List<Pair<RID, Float>> results = index.findNeighborsFromVector(vector, 10, allowed);

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions