Querying
While some of the property definition in the example may have felt a bit verbose (we’ll get into more patterns later to help manage the redundancy), but it starts to pay off by the expressiveness from being able to query all the information in your workspace.
First, let’s update the workspace config file to tell Knowboard we want to listen on a specific port:
# ...exclude = [".git/**"]
[sparql_server]listen = "17878"The server works with common SPARQL clients like comunica-sparql which we’ll use for the examples:
$ npm install -g @comunica/query-sparql$ comunica-sparql http://localhost:17878/sparql -t table 'SELECT ?s ?p ?o WHERE { ?s ?p ?o }'s p o--------------------------------------------------------------------------------------------------------------------------------------------------------https://example.knowboard.dev/authors/jane-austen http://schema.org/name Jane Austenhttps://example.knowboard.dev/authors/jane-austen http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://schema.org/Personhttps://example.knowboard.dev/authors/f-scott-fit… http://schema.org/name F. Scott Fitzgeraldhttps://example.knowboard.dev/authors/f-scott-fit… http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://schema.org/Personhttps://example.knowboard.dev/books/great-gatsby http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://schema.org/Bookhttps://example.knowboard.dev/books/great-gatsby http://schema.org/name The Great Gatsbyhttps://example.knowboard.dev/books/great-gatsby http://schema.org/author https://example.knowboard.dev/authors/f-scott-fit…https://example.knowboard.dev/books/pride-and-pre… http://schema.org/author https://example.knowboard.dev/authors/jane-austenhttps://example.knowboard.dev/books/pride-and-pre… http://schema.org/name Pride and Prejudicehttps://example.knowboard.dev/books/pride-and-pre… http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://schema.org/BookListing out all of the data in the workspace is still quite verbose, so let’s write a more specific query:
PREFIX schema: <http://schema.org/>
SELECT ?bookName ?authorName WHERE { ?book a schema:Book ; schema:name ?bookName ; schema:author ?author . ?author schema:name ?authorName .}$ comunica-sparql http://localhost:17878/sparql -t table -f query.rqbookName authorName------------------------------------------------The Great Gatsby F. Scott FitzgeraldPride and Prejudice Jane AustenThis documentation will focus mainly on Knowboard-specific patterns for using SPARQL, but there are other general guides to learn more about the query language itself.