Skip to content

search: Implement query based search contexts

Administrator requested to merge ts/search-contexts-repository-query into main

Created by: tsenart

Context

This PR is a work-in-progress to extend search contexts to be able to be defined in terms of a restricted Sourcegraph search query (e.g. repo:^github\.com/org (rev:HEAD or rev:bar)). It also allows specifying file: and lang: filters for monorepos.

It works by substituting each context param in a runtime query with its defined query (if any).

Demo

https://user-images.githubusercontent.com/67471/147663887-40c87cb8-7751-4cda-89fe-9e4fc3e5dbbb.mp4

TODO

  • Extend existing UI to have a repository query field. Would be nice to get search syntax highlighting and client side validation.
  • Create new UI for adding selected search terms as a search context (from the search UI).
  • Ask @rvantonder to review and optimize query rewriting and validation bits since I'm quite new to these APIs.
  • Figure out best way to evaluate repo query in index_options.go to determine which revs to index. We could either run an actual search or statically convert the repository query to repo options and then use searchrepos.Resolver. Because of OR/AND complexities, I'm leaning towards the first one. Opinions wanted (@rvantonder, @sourcegraph/search-core)
  • Limit user added search contexts on dotcom to MAX revs to limit impact on index search cluster.

Merge request reports

Loading