So when I run this SPARQL query on the DBpedia SNORQL interface it works --
select *
{ ?s rdf:type <http://dbpedia.org/class/yago/Company108058098> }
limit 10
But a similar query doesn't work --
select *
{ ?s dct:subject <http://dbpedia.org/page/NEC> }
limit 5
Can anyone tell me where am I doing it wrong ?
Related
I'm new to SPARQL hope someone could help me.
The problem is that if I run the following query on dbpedia sparql:
SELECT DISTINCT ?class WHERE {
?s a ?class.
}
it returns:
result query
I would like to remove the results that has this two prefix: "http://www.w3.org/2002/07/owl" and "http://www.w3.org/2000/01/rdf-schema", now the query is:
SELECT DISTINCT ?class WHERE {
?s a ?class.
FILTER ( !strstarts(str(?class), "http://www.w3.org/2002/07/owl") ).
FILTER ( !strstarts(str(?class), "http://www.w3.org/2000/01/rdf-schema") ).}
but it returns only one result:
http://www.w3.org/1999/02/22-rdf-syntax-ns#Property
If I execute the same query on istat sparql these queries work fine.
So the question is, why on dbpedia my queries does not work as expected?
Thanks
I guess I am stuck at the basics with SPARQL. Can someone help ?
I simply wnat to filter all subjects containing "Mountain" of an RDS database.
Prefix lgdr:<http://linkedgeodata.org/triplify/> Prefix lgdo:<http://linkedgeodata.org/ontology/>
Select * where {
?s ?p ?o .
filter (contains(?s, "Mountain"))
} Limit 1000
The query leads to an error:
Virtuoso 22023 Error SL001: The SPARQL 1.1 function CONTAINS() needs a string value as first argument
You can get it to "work" using:
Prefix lgdr:<http://linkedgeodata.org/triplify/> Prefix lgdo:<http://linkedgeodata.org/ontology/>
Select * where {
?s ?p ?o .
filter (contains(str(?s), "Mountain"))
} Limit 1000
Note the additional str in the query.
However, that results in
Virtuoso S1T00 Error SR171: Transaction timed out
and I am not sure how to deal with that.
But in principle in works: When you use
Limit 1
you get
s p o
http://linkedgeodata.org/ontology/MountainRescue http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/2002/07/owl#Class
I'm doing a small exercise on sparql. Using Dbpedia Endpoint, I need to count number of triples.
This is my query
// Get the number of triples //
SELECT (COUNT(*) as ?Triples) WHERE { ?s ?p ?o}
-------------------------------------------------------
OUTPUT:
( ?Triples = 1625382483 )
Just wondering are the query and the result right?
Is this how you get the number of triples?
You can sanity check many things by executing queries directly on a SPARQL endpoint, rather than going through Jena or other intermediary clients. For instance, your query on the DBpedia form, and its results, which shows all triples in that triplestore (currently 1,625,382,483).
If you want the count of triples only within the DBpedia named graph (currently 438,336,517), you'll need to specify that, either in the SPARQL form Default Data Set Name (Graph IRI), or directly in the query, as in --
SELECT (COUNT(*) as ?Triples)
WHERE
{ GRAPH <http://dbpedia.org>
{ ?s ?p ?o }
}
-- or --
SELECT (COUNT(*) as ?Triples)
FROM <http://dbpedia.org>
WHERE { ?s ?p ?o }
I am a newbie to SPARQL. Though I have read some materials about RDF and SPARQL, I still cannot understand the meaning of the mysterious SPARQL query on the LinkedGeoData SPARQL endpoint
Prefix lgdr:<http://linkedgeodata.org/triplify/>
Prefix lgdo:<http://linkedgeodata.org/ontology/>
Select * { ?s ?p ?o . }
Limit 1000
What does this oversimplified where condition ?s ?p ?o mean?
The query you ask about will return 1,000 triples from the endpoint with no filter or condition applied i.e. {?s ?p ?o. } will match any triple.
It's similar to SELECT * FROM aView in SQL if aView was a union of all, or most, of the tables in a SQL database.
I am trying to use the following query on Japanese dbpedia SPARQL Endpoint
select ?s (group_concat(?album_ja ; separator = "|") AS ?name_album_ja_csv) where{
values ?sType { dbpedia-owl:Song
dbpedia-owl:Single
} .
?s a ?sType .
?s (dbpedia-owl:album|^dbpedia-owl:album)* ?albums;rdfs:label ?album_ja
}group by ?s order by ?s offset 0 limit 10
but I get this error Virtuoso 42000 Error The estimated execution time 1005 (sec) exceeds the limit of 400 (sec). Almost any query involving group by has this problem. Is this a server problem? Is my query inefficient? How can I get around it?
I'm not sure exactly what you're trying to do, but since ?o isn't used in the results, you can get rid of it. Even after you do that, though, you'll still have the same problem. You need to change the property path somehow. I don't think that you actually need arbitrary length paths in both directions. You could use ? instead of * to say "path of length 0 or 1" and thus:
select ?s
(group_concat(?album_ja ; separator = "|") AS ?name_album_ja_csv)
where {
values ?sType { dbpedia-owl:Song dbpedia-owl:Single }
?s a ?sType .
?s (dbpedia-owl:album|^dbpedia-owl:album)? ?album_ja
}
group by ?s
limit 100
SPARQL results
Note that a path of length 0 is going to be a link to itself, so one value of ?album_ja is always going to be the same as ?s. Is this really what you want?