Questions tagged [sparql]

SPARQL (pronounced "sparkle", a recursive acronym for SPARQL Protocol and RDF Query Language) is a set of specifications by W3C that provide languages and protocols to query and manipulate RDF graph content on the Web or in an RDF store.

SPARQL

SPARQL (pronounced "sparkle", a recursive acronym for SPARQL Protocol and RDF Query Language) is a set of specifications by W3C that provide languages and protocols to query and manipulate RDF graph content on the Web or in an RDF store.

SPARQL 1.0

SPARQL 1.0 is the original version of SPARQL, and simply provides a query language for RDF. The language is based on Graph Pattern matching and provides 4 forms of query:

  1. ASK WHERE { } - An ASK query simply asks whether there exists a match for the Graph Pattern stated in the WHERE clause in the data being queried.
    This returns a Boolean SPARQL Results Set containing a True/False response.
  2. SELECT * WHERE { } - A SELECT query finds all the solutions that match the Graph Pattern and returns the desired parts of them. Results can be ORDERed as desired and use LIMIT and/or OFFSET for paging purposes. This is the most commonly used query form and corresponds in function (if very differently in syntax and semantics) to the SQL that many developers coming to the Semantic Web are familiar with.
    This returns a SPARQL Result Set containing the solutions.
  3. DESCRIBE <http://example.org> - A DESCRIBE query gets the description of one/more resources from the data. The query engine is free to decide what constitutes a description. A WHERE clause may be used to select what resources are to be described.
    This returns an RDF Graph.
  4. CONSTRUCT { } WHERE { } - A CONSTRUCT query takes solutions that match the WHERE clause and uses them to construct a new RDF Graph.
    This returns an RDF Graph.

SPARQL 1.0 Example

A SPARQL 1.0 query might look like the following:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT *
FROM <http://default>
WHERE
{
  ?s a ?type .
  OPTIONAL
  {
    ?s rdfs:label ?label .
    FILTER (LANGMATCHES(?label, "en"))
  }
}
ORDER BY ?label
LIMIT 10

This query looks for things with a type in the graph <http://default> and optionally includes their labels provided those labels are in English. It orders the results by the label limiting the results returned to 10.

SPARQL 1.1

SPARQL 1.1 is a major extension to the SPARQL ecosystem approved as a W3C Recommendation in March 2013. It provides many extensions to the existing query language including:

  • Project expressions in SELECT, e.g. (?x + ?y AS ?z)
  • Aggregates, e.g. COUNT(), GROUP BY, and HAVING
  • Property Paths, e.g. {?x ex:predicate+ ?y}
  • EXISTS and NOT EXISTS filters
  • MINUS clause for subtractive negation
  • SERVICE clause for federated querying
  • Subqueries
  • Many new built in functions particularly around string and date manipulation

It also adds a number of entirely new features into the ecosystem including:

See the SPARQL 1.1 Implementation Report for implementations that have reported compliance test results. See the SPARQL Wikipedia article for examples, extensions, and another list of implementations.

5278 questions
2
votes
3 answers

Sparql Filter : get all details of a match

I have following sparql query: PREFIX spec: PREFIX foaf: PREFIX constraint: SELECT (sample(?FName) as ?fName) (sample(?Midname) as ?midname)…
Ravish
  • 2,173
  • 4
  • 33
  • 51
2
votes
1 answer

Sparql query for wgs84 rdf

I have this RDF file and i like to make query to select the individual mark, but i can't. please can some one help me
kammoun
  • 23
  • 4
2
votes
1 answer

SPARQL prefix wildcard

I'm attempting to write a SPARQL query which would allow me to find all nodes which are reachable from a given node. At the moment every edge has the prefix http://www.foo.com/edge# and there are 3 possible edges (uses, extends, implements). While I…
user1690293
  • 403
  • 4
  • 13
2
votes
1 answer

Querying DBpedia for 'Wikipage disambiguates' using SPARQL

I've just started working with DBpedia and SPARQL. I want to use it as followed: Getting an input x, I want to return the "Wikipage disambiguates" of x, where x is a possible value of "Wikipage redirect". In other words, I want to search all the…
Maoritzio
  • 1,062
  • 2
  • 11
  • 28
2
votes
1 answer

SPARQL - getting amounts of optional data and combining rows

I want to request the amounts of rooms in a venue: This is what i get: ah:room - ah:room …
Martijn Mellens
  • 524
  • 7
  • 23
2
votes
1 answer

SPARQL select query returns unexpected results in JENA

I've been using Jena for a while in my research project, however I have recently been trying to use SPARQL queries to help my program do some tasks more efficiently. I tested a set of queries using Twinkle ( http://www.ldodds.com/projects/twinkle/…
roscminni
  • 65
  • 7
2
votes
2 answers

Several SPARQL queries via Jena command line

Is it possible to put several SPARQL queries into one file (like SQL SELECTs) and use it for tdbquery.bat Jena command line tool? tdbquery.bat --loc=../data_dir --query=several_queries.sparql I can do it in Java code but may be I can do it via…
gmlvsv
  • 945
  • 1
  • 8
  • 28
2
votes
1 answer

NoSuchMethod exception when running simple SPARQL query in JENA

Hi i've just started using Jena and wanted to run a few SPARQL queries. I got the following exception when I tried to run a basic select query: Caused by: java.lang.NoSuchMethodError:…
roscminni
  • 65
  • 7
2
votes
1 answer

How to retrieve individuals from owl using SPARQL queries?

I can retrieve individuals from my ontology using following query: SELECT ?indiv WHERE { ?indiv rdf:type:Fruit } I get results such as Apple, Orange, etc., but when I wrote this query in Java, I get the following exception: Exception in thread…
Rosh
  • 699
  • 1
  • 11
  • 30
2
votes
2 answers

How can I increase performance of sparql query while using inferencing?

I want to increase performance of my sparql queries. I have to run all type of sparql query. I have total 17,500,000 triples in the graph and i have other graph containg only knowledge. this graph containing same as and subclassOf property. Total…
Raxit
  • 242
  • 2
  • 10
2
votes
1 answer

SPARQL regex FILTER with unicode characters

I have following SPARQL query which I am using with virtuoso and pyodbc I tried this : queryUnicode = u""" SELECT ?subject ?pred ?value WHERE { ?subject ?pred ?value. FILTER ( regex(str(?value), 'abcd\\u00e9.*$', "i") ) }""" But if gave…
Ksh Padalkar
  • 241
  • 2
  • 7
2
votes
1 answer

Jena TDB insert statement resulting in empty fields

I am using Jena APIs to insert and update triples in Jena TDB. My design is such that each of the insert operation is within the transaction control. For example: dataset.begin (ReadWrite.WRITE) try { // 1st insert operation …
2
votes
1 answer

"DESCRIBE" SPARQL query on Dbpedia

I want to extract dbpedia data to RDF using "DESCRIBE" query. For instance, if i type: PREFIX rdf: PREFIX db: PREFIX prop: DESCRIBE ?movie…
expx
  • 23
  • 4
2
votes
2 answers

Jena/Sparql/Arq: injecting some statements in the model during the query

I have build a small RDF model: it only contains a few triples describing some items on the human genome. I want to retain only those items overlapping some genomic segments (say a "gene"), stored in another relational database. This database of…
Pierre
  • 31,741
  • 29
  • 101
  • 180
2
votes
2 answers

dbpedia sparql endpoint character encoding

I have a problem with the DBpedia SPARQL endpoint. When I call this query it doesn't return any results: SELECT DISTINCT * WHERE { rdfs:label ?label . OPTIONAL { …
Piotr Idzikowski
  • 713
  • 5
  • 13
1 2 3
99
100