Skip to content

search: add support for negated patterns to searcher

Warren Gifford requested to merge sh/support-negation-for-searcher into main

Created by: stefanhengl

relates to #13274 (closed)

This PR adds support for negated patterns to searcher. Upstream changes in frontend to enable negation for unindexed searches will follow in a separate PR. I ran all of searcher's benchmarks (main vs. this PR) and they don't show any difference.

Limitation This PR does not add support for negated structural patterns. Why? For structural searches we first call zoekt to restrict the scope of the search before calling searcher. This means searcher doesn't know about the full scope of the request. However, we need the full scope to negate the matches, otherwise, we potentially miss out on all lot of matches.

Example A user searches for a structural pattern within a group of repos. Let's say the pattern is only contained in repoA and a single file, fileA, within repoA. Zoekt will return repoA and fileA and searcher will only be called on repoA and fileA. However, the negated search would have to return all files in all repos (including repoA) except fileA.

If we want to enable negated patterns for structural search we need to do it (mostly) outside searcher. We should discuss this and then handle it in a different PR.

A request with a negated structural pattern will return a 400. However, we have a guard in frontend that prevents negated patterns for structural searches, so we should never see the 400 in production.

Merge request reports

Loading