High-level query helpers over an OKF bundle.
Filters are ANDed together. Unknown filter keys are ignored (match fails).
Summary
Functions
Returns concepts that link to concept_id (backlinks).
Finds a concept by id.
Queries concepts matching all given filters.
Returns all distinct tags in the bundle, sorted.
Returns all distinct concept types in the bundle, sorted.
Types
@type filter() :: {:type, String.t() | Regex.t()} | {:tag, String.t()} | {:id, String.t() | Regex.t()} | {:has_resource, boolean()}
A single query filter.
{:type, String.t() | Regex.t()}— exact or regex match onconcept.type{:tag, String.t()}— concept must include this tag{:id, String.t() | Regex.t()}— exact or regex match onconcept.id{:has_resource, boolean()}— require / forbid a non-emptyresource
Examples
{:type, "BigQuery Table"}
{:type, ~r/Table/}
{:tag, "sales"}
{:id, "tables/orders"}
{:id, ~r/^tables\//}
{:has_resource, true}
Functions
@spec backlinks(ExOKF.Bundle.t(), String.t()) :: [ExOKF.Concept.t()]
Returns concepts that link to concept_id (backlinks).
Parameters
bundle(ExOKF.Bundle.t()) — loaded OKF bundleconcept_id(String.t()) — target concept id
Examples
iex> bundle = ExOKF.TestSupport.sample_bundle()
iex> ids = ExOKF.Query.backlinks(bundle, "tables/customers") |> Enum.map(& &1.id)
iex> "tables/orders" in ids
true
@spec get(ExOKF.Bundle.t(), String.t()) :: ExOKF.Concept.t() | nil
Finds a concept by id.
Parameters
bundle(ExOKF.Bundle.t()) — loaded OKF bundleid(String.t()) — concept id, e.g."tables/orders"
Returns
The concept, or nil if not found.
Examples
iex> bundle = ExOKF.TestSupport.sample_bundle()
iex> ExOKF.Query.get(bundle, "tables/orders").title
"Orders"
@spec query(ExOKF.Bundle.t(), [filter()] | keyword()) :: [ExOKF.Concept.t()]
Queries concepts matching all given filters.
Parameters
bundle(ExOKF.Bundle.t()) — loaded OKF bundlefilters([t:filter/0] | keyword()) — AND-combined filters
Returns
A list of matching ExOKF.Concept.t() (order follows ExOKF.Bundle.concepts/1).
Examples
iex> bundle = ExOKF.TestSupport.sample_bundle()
iex> ids = ExOKF.Query.query(bundle, type: "BigQuery Table") |> Enum.map(& &1.id)
iex> "tables/orders" in ids
true
@spec tags(ExOKF.Bundle.t()) :: [String.t()]
Returns all distinct tags in the bundle, sorted.
Parameters
bundle(ExOKF.Bundle.t()) — loaded OKF bundle
Examples
iex> bundle = ExOKF.TestSupport.sample_bundle()
iex> "sales" in ExOKF.Query.tags(bundle)
true
@spec types(ExOKF.Bundle.t()) :: [String.t()]
Returns all distinct concept types in the bundle, sorted.
Parameters
bundle(ExOKF.Bundle.t()) — loaded OKF bundle
Examples
iex> bundle = ExOKF.TestSupport.sample_bundle()
iex> ExOKF.Query.types(bundle)
["BigQuery Dataset", "BigQuery Table"]