Semantics Hello World

In this exercise, you will

  1. Insert RDF triples into a database
  2. Query the triples using SPARQL

This is a highly simplified example - we'll break some rules, but that's OK!

Enable the triple index

  1. Point your browser to the MarkLogic app services on http://localhost:8000/appservices. (Replace localhost with the hostname).
  2. Choose the 'Documents' database and click 'Configure'
  3. Select the 'Semantics' checkbox

Insert some triples

  1. Point your browser to http://localhost:8000/qconsole (Replace localhost with the hostname of your MarkLogic server if necessary). If you're doing this from a fresh install, Query Console will be pointing at the Documents database (look at the top left corner). The text box shows a "hello world" XQuery example.
  2. Remove <p>hello world</p> from the text box.
  3. Paste this into the text box and hit "run":

    Here, you are inserting 3 triples. Each triple is of the form ("subject", "predicate", "object") where the subject and predicate are IRIs (like URIs, but internationalized) and the object is, in this case, a simple string. It will generate output, something like

Verify triple count

Check that you have some triples.

  1. In Query Console, click "+" to open a new tab.
  2. Remove <p>hello world</p> from the text box.
  3. Paste this query into the text box and hit "run":

    It should return

Run a SPARQL Query

Let's run a query that asks, "Who lives in London?".

  1. In Query Console, click "+" to open a new tab.
  2. Remove <p>hello world</p> from the text box.
  3. Paste this query into the text box and hit "run":

    It should return

Next Steps

Congratulations! You inserted 3 triples into a MarkLogic database and ran a SPARQL query.

Want to do more? Try these:

Run SPARQL directly in Query Console

In Query Console, select "Query Type" = SPARQL, and type in SPARQL queries

Create and insert lots of triples

See documentation for sem:rdf-builder()

Load triples from a file

References

Getting Started with Semantics

Loading Data

Comments