flora-server icon indicating copy to clipboard operation
flora-server copied to clipboard

Composable search language

Open tchoutri opened this issue 1 year ago • 1 comments

There are a number of search qualifiers, and it's not yet possible to compose them. Some of them cannot be composed, so we must have some kind of algebra that determines how qualifiers can be composed. Maybe look at how Github does it?

There are a number of questions to answer:

  • Which modifiers are mutually-exclusive / cannot be composed?
    • How do we model a query so that one modifier takes precedence regarding the source? To search for advisories within the dependents of a packages, depends: and hsec: could in theory be both used.
  • Right now, the search results are taken from PostgreSQL. Is this the appropriate storage engine?

Package qualifiers

  • depends:<@namespace>/<packagename>: Shows the dependents page for a package
  • in:<@namespace> <search term>: Searches for a package name in the specified namespace
    • in:<@namespace>: Lists packages in a namespace
  • exe:<search term> look for packages that expose an executable with a high proximity to the search term

Advisories

  • hsec:<search term> look for advisories whose summary contain a high proximity to the search term

Search Language AST:

data SearchQuery
  = PackageName SearchOperator Text SearchQuery
  | PackageNamespace MembershipOperator Text SearchQuery
  | Nil
  deriving stock (Eq, Ord, Show)

data EqualityOperator 
  = NotEquals
  | Equals
  deriving stock (Eq, Ord, Show)

data MembershipOperator
  = In
  | NotIn
  deriving stock (Eq, Ord, Show)

-- Only for executables right now
data OwnershipOperator 
  = Has Object 
  | HasNot Object
  deriving stock (Eq, Ord, Show)

data Object
  = Executable Name
  deriving stock (Eq, Ord, Show)

Then a transformation from SearchQuery to SQL fragments will happen.

tchoutri avatar Dec 27 '24 15:12 tchoutri