Skip to content

search: introduce type:notebook and select:notebook.block

Warren Gifford requested to merge notebooks-search into main

Created by: bobheadxi

This is the result of @tsenart and I's #fy23-q1-sourcegraph-hackathon project this week - searching search notebooks! Putting this PR up as a record of what we got through this week and in case anyone is curious or interested in taking this further.

Co-authored-by: Tomás Senart [email protected]

What's done:

  • type:notebook over notebook titles and content
  • select:notebook.block and select:notebook.block.[blocktype] (e.g. select:notebook.block.query) to get block matches
  • Rendering notebook results and notebook block results within search
  • Completions for the new type and select stuff

What's broken/subpar:

  • notebook: and -notebook: fields, the intention is to filter on notebook titles with these fields
  • Notebook block matches are done by performing regex over marshalled blocks :) We might need a more effective approach here
  • No query match highlights on block matches
  • Query syntax
  • Code awkwardness (untyped blocks!) due to OSS/Enterprise split of notebooks backend code. We might want to look into a way to "register" search job handlers from enterprise code to avoid this. Types for the blocks are very hack in general, some workarounds were needed in the frontend too due to varying internal representations

Other thoughts:

  • This is the first non-repo-oriented result type, so some extension to the search internals was needed (generic ID), but also needed to be hacked around (zero-value repo field)
  • Maybe we don't want to support block rendering like this as well, and index the notebook as a single entity instead to only show notebooks.
    • This would fit in better with potentially introducing a generic "thing" search result type that can be fulfilled by different data sources, and dramatically reduce the scope of this feature

Brief demo: #fy23-q1-sourcegraph-hackathon: search search notebooks final demo (short)

Scratch notes: https://sourcegraph.com/notebooks/Tm90ZWJvb2s6NTE5

Test plan

The backend features for this are feature-flagged, frontend might need it too to hide the completions

App preview:

Merge request reports

Loading