search: compose lucky rules for lang, type, unordered
Created by: rvantonder
Stacked on https://github.com/sourcegraph/sourcegraph/pull/37059
This statically composes some of the previous rules, so that you can get pretty nice and complex interpretations for a query like:
go commit monitor code
runs as any of (in priority):
- usual literal search
-
type:commit lang:Go monitor code
(triggertype
andlang
rules) -
type:commit go monitor code
(triggertype
rule) -
lang:Go commit monitor code
(triggerlang
rule) -
type:commit lang:Go (monitor AND code)
(triggerlang
rule andcommit
rule, then unorder) - etc.
In the ideal solution, we don't want to enumerate the composition of these rules statically like I'm doing here, but generate them based on their properties. But I don't yet know what properties play well and what combinators will be useful for generating, so see this as me exploring that direction and making observations.
Observations so far:
- There is an either/or/both strategy where ordering of rule application doesn't matter, and the rules are disjoint. For example, applying
lang
andtype
rules are disjoint, and their application order doesn't matter. We prefer to run a search where both applies, before attempting the either/or property. - I haven't thought deeply about it, but I believe the either/or/both strategy ensures unique results (important characteristic, if we want to minimize the deduplication).
- There is a general multi-pattern strategy that composes on top of disjoint rules that turn patterns into parameters--one example is interpreting
unordered
patterns / rule. - It seems pretty clear that the multi-pattern strategy is prone to duplication.
Test plan
Updated tests.