Skip to content

feat: allow filtering neighbor expansion by vertex ID#1895

Open
vishwakt wants to merge 1 commit into
aws:mainfrom
vishwakt:issue-274-expand-filter-by-id
Open

feat: allow filtering neighbor expansion by vertex ID#1895
vishwakt wants to merge 1 commit into
aws:mainfrom
vishwakt:issue-274-expand-filter-by-id

Conversation

@vishwakt

@vishwakt vishwakt commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Closes #274

Problem

When expanding a node's neighbors, you could only narrow the results by property values. There was no way to target a specific neighbor by its ID, which is what the issue asks for.

Approach

I'd love a sanity check on the approach before polishing further, happy to change any of it.

1. UI (NodeExpandFilters / NodeExpandContent)

  • Added "ID" as the first option in the "Filter to narrow results" dropdown.
  • ID is offered even for neighbor types that have no searchable attributes, so the filter section now renders whenever a neighbor type is selected (previously it was hidden when a type had no searchable attributes).
  • The ID is not a real property, so NodeExpandContent partitions ID filter rows out of the property filterCriteria and into a new filterByIds request field. A reserved sentinel name (ID_FILTER_NAME) marks the ID option; it never reaches the connectors.

2. Request contract (NeighborsRequest)

  • Added an optional filterByIds?: Array<VertexId>. This keeps ID filtering fully separate from the property-based filterCriteria path.

3. Connectors each translate filterByIds into their native id filter:

  • Gremlin: hasId(...)
  • openCypher: ID(tgt) IN [...]
  • SPARQL: FILTER(?neighbor IN (...))

Testing

  • Added ID-filter cases to the Gremlin, openCypher, and SPARQL oneHop* template tests (single ID, and multiple IDs combined with a type filter).
  • pnpm checks and pnpm test pass (2071 tests).

Open questions for maintainers

  1. ID filter placement — I put "ID" at the top of the dropdown and default a new filter row to it. Happy to move it to the bottom if you'd rather keep property filters as the default.
  2. Always showing the filter section — this is a small behavior change for types with no searchable attributes. It seemed necessary so ID is always filterable, but let me know if you'd prefer to gate it differently.
  3. Multiple IDs — multiple ID rows are combined as an IN list (OR). Property filters remain AND-combined. Let me know if you'd expect different semantics.

Add "ID" as a selectable option in the neighbor expansion filter
dropdown so a specific neighbor can be found by its ID. Because the ID
is not a real property, it is partitioned out of the property filter
criteria into a new filterByIds request field and handled directly by
each connector's neighbor query:

- Gremlin: hasId(...)
- openCypher: ID(tgt) IN [...]
- SPARQL: FILTER(?neighbor IN (...))

ID is always offered, even for types with no searchable attributes, so
the filter section now renders whenever a neighbor type is selected.

Closes aws#274
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Add ID to the filter drop down for neighbor expansion

1 participant