SPARQL auto-completion
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

GoDoc Build Status

Gosparqled - SPARQL Auto-Completion

Gosparqled provides a library for retrieving context-aware recommendations for a SPARQL query. The library is written in GO and is then translated into JavaScript using GopherJS.

Gosparqled demo

What is context-aware ?

By context-aware recommendation, I mean that all patterns which are connected to the element to recommend participate in the recommendation. For example, the 3rd pattern below is left out of the context of the recommendation. The reason is that none of its variables appear in the others. However, the 2nd is kept.

?s rdf:type %% RECOMMEND HERE! %% .
?s foaf:name ?name .
?o ?p "left out" .


The folder demo/ shows how gosparqled can be used with other tools such as YASR and YASQE in order to have a full-fledged SPARQL query editor with the added recommendation feature. That demo can be tested at


The recommendations are context-aware, i.e., the current state of the SPARQL query is taken into consideration when retrieving the recommendations.

In the examples below, the character < represents the position in the query to auto-complete by pressing CTRL + SPACE. The < should not be typed prior to pressing the key combination. The auto-completion is possible at any position in a triple pattern.


Recommend possible classes:

    ?s a <


Recommend possible predicates:

    ?s <


Recommend possible relations between a Person and a Document:

    ?s a <Person> .
    ?o a <Document> .
    ?s < ?o


Recommend possible terms (e.g., classes or predicates) which URI contains a keyword, case-insensitive. Below, it presents classes which contain the word movie:

    ?s a Movie<


Recommend possible path of a fixed length, written as X/. Below, recommendations about paths of lengths 2 between a Movie and a Person are returned:

    ?s a <Movie> .
    ?o a <Person> .
    ?s 2/< ?o


Recommend possible terms (e.g., classes or predicates) with the given prefix. Below, it presents only the predicates within the rdfs prefix:

PREFIX rdfs: <>

    ?s rdfs:<


Recommend content elements, e.g., literals, URIs, either at the subject or the object location.

  • Auto-completion on the object. This returns a sample of the labels, probably literals.

    SELECT * {
        ?s rdfs:label <
  • Auto-completion on the subject. This returns a list of URIs which name is John.

    SELECT * {
        < foaf:name "John" .


First, install GopherJS:

$ go get

Run the command below to create the JavaScript library. The -m flag minifies the generated JavaScript code.

$ gopherjs build -m

The following methods can then be called via JavaScript (see demo/autocompletion.js).

  • RecommendationQuery in the autocompletion namespace

    It takes in the SPARQL query with the character < indicating the position in the query to auto-complete. It returns the processed SPARQL query, which can then be sent to the SPARQL endpoint in order to retrieve the possible recommendations. The recommendations are bound to the variable ?POF.


This library is presented in If you are using this tool, please cite this work.