You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Boris Pelakh <bp...@modusoperandi.com> on 2014/05/28 16:03:46 UTC

How do I query a multi-graph model?

Hey, have a question regarding the quad api (DatasetGraph)

I am inserting quads, and can retrieve them w/o problems (via find() or iteration)

But I want to run graph-aware SPARQL queries over the data

How do I get a handle on a Model (or equivalent) that will let me do that?

(obviously getDefaultModel() doesn't see any of the data in the named graphs)



By graph-aware queries I mean something like:



select ?p ?o { GRAPH <http://updated/test> {<http://model.com/people/Mike> ?p ?o . }}



Thank you for your help,

Boris


Re: How do I query a multi-graph model?

Posted by Rob Vesse <rv...@dotnetrdf.org>.
You can run SPARQL queries over a Dataset instance, you will need to first
call DatasetFactory.create() passing your DatasetGraph instance in to wrap
it as a Dataset and then call the QueryExecutionFactory.create() method as
normal e.g.

// Assuming you already have a DatasetGraph in the variable dsg
Dataset ds = DatasetFactory.create(dsg);

// And assuming you have your query in the variable query
QueryExecution qe = QueryExecutionFactory.create(query, deg);

Rob

On 28/05/2014 15:03, "Boris Pelakh" <bp...@modusoperandi.com> wrote:

>Hey, have a question regarding the quad api (DatasetGraph)
>
>I am inserting quads, and can retrieve them w/o problems (via find() or
>iteration)
>
>But I want to run graph-aware SPARQL queries over the data
>
>How do I get a handle on a Model (or equivalent) that will let me do that?
>
>(obviously getDefaultModel() doesn't see any of the data in the named
>graphs)
>
>
>
>By graph-aware queries I mean something like:
>
>
>
>select ?p ?o { GRAPH <http://updated/test>
>{<http://model.com/people/Mike> ?p ?o . }}
>
>
>
>Thank you for your help,
>
>Boris
>