clerezza-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Minto van der Sluis <mi...@xup.nl>
Subject Querying named graphs do not give the expected results
Date Mon, 06 May 2013 11:29:02 GMT
Hi folks,

Not sure whether it is my (in)ability to write Sparql queries or
something odd is going  on. But I am having some trouble with querying
specific named graphs.

To give some context before showing the queries. I have a situation
where I have 2 named graphs:
  1) Index named <http://digimelding.nl/AStore/stamIndex> containing
references to other named graphs.
  2) A named graph <7e72ff00-48f1-11e2-bcfd-0800200c9a66> containing
actual data. The graph name is a UUID.
 
Querying the first gives expected results. But when querying the second
I do not get the results I expect.

Query 1: Show all named graphs with actual content(triples).
 SELECT distinct ?g
  WHERE {
    GRAPH ?g {
      ?s ?p ?o .
    }
  }
 
  Results in:
  +------------------------------------------+
  | g                                        |
  +------------------------------------------+
  | <7e72ff00-48f1-11e2-bcfd-0800200c9a66>   |
  | <http://digimelding.nl/AStore/stamIndex> |
  +------------------------------------------+

Query 2: To show the total number of triples present in both named graphs:
 SELECT (COUNT(?s) as ?numberOfTriples)
  WHERE {
    GRAPH ?g {
      ?s ?p ?o .
    }
  }
 
  Results in:
  +--------------------------------------------------+
  | numberOfTriples                                  |
  +--------------------------------------------------+
  | "29"^^<http://www.w3.org/2001/XMLSchema#integer> |
  +--------------------------------------------------+

Query 3: Get the number of triples present in the index graph. 
  SELECT (COUNT(?s) as ?numberOfTriples)
  WHERE {
    GRAPH <http://digimelding.nl/AStore/stamIndex> {
      ?s ?p ?o .
    }
  }
 
  Results in:
  +-------------------------------------------------+
  | numberOfTriples                                 |
  +-------------------------------------------------+
  | "1"^^<http://www.w3.org/2001/XMLSchema#integer> |
  +-------------------------------------------------+

Query 4: In my quest for the getting the results I wanted I played
around with various query forms. In my understanding thuis query should
yield the same results as the previous one. Unfortunately, it doesn't.
  SELECT (COUNT(?s) as ?numberOfTriples)
  FROM <http://digimelding.nl/AStore/stamIndex>
  WHERE {
      ?s ?p ?o .
  }
 
  Results in:
  +-------------------------------------------------+
  | numberOfTriples                                 |
  +-------------------------------------------------+
  | "0"^^<http://www.w3.org/2001/XMLSchema#integer> |
  +-------------------------------------------------+

Query 5: Every query targeted on a named graph (UUID) with the actual
content gives no results. Clearly this query should return ( total
triples 29 - index triples 1 =) 28 triples. Unfortunately it doesn't.
  SELECT (COUNT(?s) as ?numberOfTriples)
  WHERE {
    GRAPH <7e72ff00-48f1-11e2-bcfd-0800200c9a66> {
      ?s ?p ?o .
    }
  }
 
  Results in:
  +-------------------------------------------------+
  | numberOfTriples                                 |
  +-------------------------------------------------+
  | "0"^^<http://www.w3.org/2001/XMLSchema#integer> |
  +-------------------------------------------------+

My code to execute these queries on Clerezza is actually quite simple:
 
    Object results = clerezzaManager.executeSparqlQuery( query, new
SimpleMGraph() );

In here the query is just a string containing one of the queries as
shown above. Execution uses Clerezza from trunk with my committed
changes to the QueryEngine.

Does anyone know why query 4 and 5 do not yield the expected outcome?
   
Regards,

misl

-- 
ir. ing. Minto van der Sluis
Software innovator / renovator


Mime
View raw message