Skip to content

lsifstore/apidocs: optimize and improve TextSearchQuery, RepoSearchQuery, etc. logic

Administrator requested to merge sg/apidocs-util into main

Created by: slimsag

This includes various improvements to the (currently unused) apidocs package to optimize and improve behavior, including:

  • Adding query parsing logic to "pick out" possible repository names from queries, so that we can be strict about what we match against the repo name table and avoid false-positives, allowing us to actually limit our search space to specific repos if they match query terms - instead of just ranking possible-repo-name-matches higher in the result list as the prior approach tried to do.
  • Massively reduced :* tsquery prefix operator usage in TextSearchQuery, as it's very slow. We're now very cautious about when and where we utilize it.
  • Prevent emitting duplicative OR conditions as we previously did.
  • Prevent emitting empty WHERE conditions () (illegal SQL) when there are no query terms.
  • Made WHERE conditions always wrapped in ( parens ) so that we don't need to worry at the usage site where we sqlf.Sprintf("WHERE %s AND ...", condition) them in.

All changes have tests, and added new tests in some cases to catch edge cases I hadn't previously thought of.

Helps #21938

Merge request reports

Loading