View Source Guesswork.Query (Guesswork v0.8.0)

Represents an un-resolved query.

Summary

Functions

Builds a new query.

Takes a query and attempts to resolve n answers from it.

Types

opts_list()

@type opts_list() :: [
  label: boolean() | [binary()],
  knowledge_base: term(),
  query_id: binary(),
  precompute_count: integer()
]

t()

@type t() :: %Guesswork.Query{
  computation: Enumerable.t(Guesswork.Answer.t()),
  id: String.t(),
  label: boolean()
}

Functions

new(statement, opts \\ [])

@spec new(Guesswork.Ast.Statement.t(), opts_list()) :: t()

Builds a new query.

Available Options:

  • :label - Traverses plural entities looking for a specific answer sets. If a list of strings is provided only the supplied variables are traversed. The default value is false.

  • :knowledge_base (term/0) - The Guesswork.KnowledgeBase used to resolve queries. The default value is Guesswork.EmptyCollection.

  • :query_id (String.t/0) - The id used to report telemetry. Defaults to a new UUID (v4).

  • :precompute_count (integer/0) - The number of answer sets to compute when resolving a fact. This allows repeated facts (that would result in the same matches) to reuse computation. Note that, with recusive queries, this can lead to infinate searches. The default value is 0.

opts_schema()

run(query, n \\ 1)

@spec run(t(), integer()) :: Guesswork.Answer.Result.t()

Takes a query and attempts to resolve n answers from it.