Knowledge base index



Fulltext index






Cheatsheet:


The basic template of a SPARQL query as suggested by the UI initially looks like this:

SELECT [DISTINCT] [variables] WHERE {
	  [subject] [predicate] [object] .
	  [subject] [predicate] [object] .
	}
	LIMIT [LIMIT]
	ORDER BY [ASC|DESC]
Please note the following hints:
  • You may need to add a prefix depending on your data set. If prefixes are available in your source they will be suggested by our UI automatically.
  • You should end lines in where clause with dots - otherwise QLever does not know that you want to connect those two lines with an AND operation.
  • DISTINCT, LIMIT and ORDER BY are optional - you don't need to add them to your query if not necessary.
Autosuggestions are made based on your position inside the query and the input you currently type. QLever UI evaluates the query you wrote in order to make context sensitive suggestions which leads to less but more relevant suggestions. Suggestions are usually ordered by their occurrence frequency. A small badge on the current lines indicates the amount of records that matches.

If you get no suggestions that might have different reasons:
  • There are no keywords or data points that match the word your are currently typing
  • The evaluation of your existing query indicates that there will be no matches
  • You have a syntax error in you query (e.g. miss a dot at the end of a line)
  • Your QLever backend or your internet connection has gone away and does not respond anymore. This is usually indicated by a red cross on the line.
As soon as your query contains at least a standard template (as suggested by the UI) you can easily switch through placeholder positions by using the TAB key.

SELECT [PLACEHOLDER 1] WHERE {
	  [PLACEHOLDER 2]
	}
	[PLACEHOLDER 3]
This will help you to easily navigate through your code and add lines, variables and limits / ordering without navigating with your mouse or your arrow pane.
When your backend contains fulltext data (you can check in the statistics pane) you can use the fulltext search features of QLever. You can make use of them by writing a query like this:

SELECT ?person TEXT(?c) SCORE(?c) WHERE {
	  ?c ql:contains-entity ?person .
	  ?c ql:contains-word "land* moon"
	}
	TEXTLIMIT 2
	ORDER BY DESC(SCORE(?c))
In this example ?person represents the entity (subject) you filter for and ?c represents the text pattern.

Note the following features:
  • A star * can be used to search for a prefix as done in the keyword walk*. Note that there is a min prefix size depending on settings at index build-time.
  • SCORE can be used to obtain the score of a text match. This is important to achieve a good ordering in the result. The typical way would be to ORDER BY DESC(SCORE(?c)).
  • Where ?c just matches a text record Id, TEXT(?c) can be used to extract a snippet.
  • TEXTLIMIT can be used to control the number of result lines per text match. The default is 1.
Be aware that there are some limitations when using QLever / QLever UI because we do not support the full SPARQL specification as published by the W3C at the moment. Anyway there are plenty of features available already:

Features you may use:
  • PREFIX
  • SELECT [DISTINCT] ... WHERE
  • ORDER BY [ASC|DESC]
  • GROUP BY
  • LIMIT
  • FILTER REGEX(?x, "[pattern]", "i")
  • (COUNT(?x) AS ?count) ...
  • for SAMPLE, MIN, MAX, AVG, GROUP_CONCAT(separator=", ")

Full-text search features added by QLever:
  • ql:contains-[entity|word]
  • TEXTLIMIT
  • TEXT()
  • SCORE()