Sparql- how to get number of triples?
Asked Answered
T

1

7

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?

Tav answered 11/7, 2018 at 14:29 Comment(0)
H
13

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 } 
Hydroelectric answered 11/7, 2018 at 16:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.