Autocomplete Index

The Autocomplete index offers suggestions for the IRIs’ local names in the SPARQL editor, the View Resource page, and in the Search RDF resources box. It is an open-source GraphDB plugin that builds an index over all IRIs in the repository plus some additional well-known IRIs from RDF4J vocabularies.

The index is disabled by default. In the Workbench, you can enable it from Setup ‣ Autocomplete.

_images/autocomplete-enable.png

In case you are getting peculiar results and you think the index might be broken, use the Build Now button.

_images/autocomplete-build-now.png

If you try to use autocompletion before it is enabled, a tooltip will warn you that the index is off and provide a link for building it.

_images/autocomplete-enable-link.png

You can also enable it with a SPARQL query from the Workbench SPARQL editor.

How the index works

All IRIs and their labels are split into words (tokens). During search, the whole words or their beginnings are matched.

For each IRI, the index includes the following:

  • The text of the IRI local name is tokenized;

  • If the IRI is part of a triple <IRI rdfs:label ?label>, the text of the label literal is tokenized and indexed;

  • If the IRI is part of a triple <IRI ?p ?label>, and ?p is added to the index config as label predicate, then the text of the ?label is tokenized and indexed for this IRI. You can add a new label via the right-hand button in the Autocomplete screen, which will open this dialog box:

_images/autocomplete-add-label.png

Local name tokenization

Local names are split by special characters (e.g., _, -), or in cases when they contain camelCase and/or numbers. For example:

IRI

Local name tokens

http://dbpedia.org/resource/Bulgarian_Tournament_Cup

Bulgarian Tournament Cup

http://dbpedia.org/resource/Post-rock

Post rock

http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#ChardonnayGrape

Chardonnay Grape

http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#USRegion

US Region

http://purl.org/dc/terms/ISO639-3

ISO 639 3

Search strings

You can search for one or more words. When searching for multiple words, they can be separated with space, or with - and _ symbols, in which case these will be required to be present in the matched text as well. You can also use camelCase notation to split the search string into multiple words.

Once the search string has been split into words, search is case-insensitive. When typing multiple words, each of them is treated as full match search and must be fully typed except for the last one, which is treated as startsWith. The order of the search string words is irrelevant, e.g., whiteWin would return the same results as wineWhit.

Some examples:

Search string

Found IRI

“Tour”

http://dbpedia.org/resource/Bulgarian_Tournament_Cup

“white win” OR “whiteWin”

http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteWine
http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteTableWine

“uk-wal”

https://www.bbc.com/news/uk-wales-44849196

“63”

http://purl.org/dc/terms/ISO639-3

Autocomplete in the SPARQL editor

For the examples below, we will be using the W3C wine ontology dataset that you can import in your repository.

To start autocompletion in the SPARQL editor, use the shortcuts Alt+Enter / Ctrl+Space / Cmd+Space depending on your OS and the way you have set up your shortcuts.

You can use autocompletion to:

  • Search for a single word in all IRIs:

    _images/autocomplete-single-word-in-all-IRIs.png
  • Search only for IRIs that start with a certain prefix:

    _images/autocomplete-IRI-starts-with-prefix.png
  • Search for more than one word:

    _images/autocomplete-multiple-words.png
  • Indexed text is split where digits or digit sequences are found, so you can also search by number:

    _images/autocomplete-search-by-number.png

Autocomplete in the View resource box

To use the autocompletion feature to find a resource, go to the GraphDB home page, and start typing in the View resource field.

_images/autocomplete-view-resource.png

You can also autocomplete resources in the Search RDF resource box, which is visible in all GraphDB screens in the top right corner and works the same way as the View resource field in the home page. Clicking the icon will open a search field where you can explore the resources in the repository.

_images/autocomplete-search-rdf-resource.png

Workbench queries

You can also work with the autocomplete index via SPARQL queries in the Workbench SPARQL editor. Some important examples:

  • Check if the index is enabled

    ASK WHERE {
        _:s <http://www.ontotext.com/plugins/autocomplete#enabled> ?o .
    }
    
  • Enable the index

    INSERT DATA {
        _:s  <http://www.ontotext.com/plugins/autocomplete#enabled> true .
    }
    
  • Autocomplete IRIs (here with the wines example from earlier)

    SELECT ?s WHERE {
        ?s <http://www.ontotext.com/plugins/autocomplete#query> "win"
    }