RDF.Query.bgp

You're seeing just the function bgp, go back to RDF.Query module for more information.

Creates a RDF.Query.BGP struct.

A basic graph pattern consist of single or list of triple patterns. A triple pattern is a tuple which consists of RDF terms or variables for the subject, predicate and object of a RDF triple.

As RDF terms RDF.IRIs, RDF.BlankNodes, RDF.Literals or all Elixir values which can be coerced to any of those are allowed, i.e. RDF.Vocabulary.Namespace atoms or Elixir values which can be coerced to RDF literals with RDF.Literal.coerce/1 (only on object position). On predicate position the :a atom can be used for the rdf:type property.

Variables are written as atoms ending with a question mark. Blank nodes which in a graph query patterns act like a variable which doesn't show up in the results can be written as atoms starting with an underscore.

Here's a basic graph pattern example:

[
  {:s?, :a, EX.Foo},
  {:s?, :a, EX.Bar},
  {:s?, RDFS.label, "foo"},
  {:s?, :p?, :o?}
]

Multiple triple patterns sharing the same subject and/or predicate can be grouped:

  • Multiple objects to the same subject-predicate pair can be written by just writing them one by one in the same triple pattern.
  • Multiple predicate-objects pair on the same subject can be written by grouping them with square brackets.

With these, the previous example can be shortened to:

{
  :s?,
    [:a, EX.Foo, EX.Bar],
    [RDFS.label, "foo"],
    [:p?, :o?]
}