lsifstore/apidocs: optimize and improve TextSearchQuery, RepoSearchQuery, etc. logic
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 inTextSearchQuery
, 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 wesqlf.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