Querying the Local RDF Service

We’re going to need some RDF data. To keep it simple, we’ll take the RDF description we generated in the previous chapter for a book resource—the book graph:

 iex>​​ ​​graph_context​​ ​​RDFGraph
 RDFGraph
 
 iex>​​ ​​graph_create​​ ​​read_graph(​​"book.ttl"​​)
 #GraphCommons.Graph<type: rdf, file: "", data: "">
 
 iex>​​ ​​graph_info
 %GraphCommons.Service.GraphInfo{
  file: "",
  labels: ["Book", "Organization", "Person"],
  num_edges: 27,
  num_nodes: 8,
  type: :rdf
 }

Here we selected the RDFGraph graph service and then created a new graph using the book.ttl stored graph.

Now let’s have a look at the SELECT and CONSTRUCT query forms.

SELECT

Let’s use a simple SELECT query that returns all the RDF terms ...

Get Exploring Graphs with Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.