Skip to content

[Feature]: Add notebook-scoped search to search endpoints #574

@richardsolomou

Description

@richardsolomou

Feature Description

Add an optional notebook_id parameter to the search endpoints (/api/search and /api/search/ask) so that searches can be scoped to a specific notebook. When notebook_id is provided, results are filtered to only sources linked to that notebook (via the reference table) and notes linked to that notebook (via the artifact table). When omitted, behavior is unchanged (global search).

Why would this be helpful?

Currently, search always returns results from all notebooks. Users working within a specific notebook context often want to search only within that notebook's sources and notes, making results more relevant and reducing noise. This is especially important as users accumulate more content across many notebooks.

Proposed Solution (Optional)

  • Add optional notebook_id field to SearchRequest and AskRequest API models
  • Pass notebook_id through the API router to domain search functions (text_search, vector_search)
  • Thread notebook_id through the ask graph state and config
  • Create a database migration redefining fn::text_search and fn::vector_search to accept a $notebook_id parameter and filter using existing relationship tables:
    • Sources: AND id IN (SELECT VALUE in FROM reference WHERE out = $notebook_id)
    • Notes: AND id IN (SELECT VALUE in FROM artifact WHERE out = $notebook_id)
  • When notebook_id is NONE, original unfiltered queries run

Additional Context

This is a non-breaking change. The notebook_id parameter is optional, so all existing API clients continue to work without modification.

Contribution

  • I am a developer and would like to work on implementing this feature (pending maintainer approval)

Metadata

Metadata

Assignees

No one assigned

    Labels

    readyApproved and ready to be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions