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
Feature Description
Add an optional
notebook_idparameter to the search endpoints (/api/searchand/api/search/ask) so that searches can be scoped to a specific notebook. Whennotebook_idis provided, results are filtered to only sources linked to that notebook (via thereferencetable) and notes linked to that notebook (via theartifacttable). 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)
notebook_idfield toSearchRequestandAskRequestAPI modelsnotebook_idthrough the API router to domain search functions (text_search,vector_search)notebook_idthrough the ask graph state and configfn::text_searchandfn::vector_searchto accept a$notebook_idparameter and filter using existing relationship tables:AND id IN (SELECT VALUE in FROM reference WHERE out = $notebook_id)AND id IN (SELECT VALUE in FROM artifact WHERE out = $notebook_id)notebook_idisNONE, original unfiltered queries runAdditional Context
This is a non-breaking change. The
notebook_idparameter is optional, so all existing API clients continue to work without modification.Contribution