Hello All,
I have a few queries relating to SDB and SPARQL query over it.
I am using the Store in SDB in the following manner: one store having
multiple named graphs.
I insert and read data from named graphs (wrapped around GraphSDB) and use
the model API to it (when not using SPARQL)
Now, I wrote a SPARQL query to access the data in the store by using a
DataSet created on the store.
*Dataset dataset = DatasetStore.create(store);*
and ran my sparql query over this dataset (there is data in the named graph
in the store).
The sparql query is of the form :
CONSTRUCT {?x ?y ?z}
WHERE {SELECT {?x ?y ?z} WHERE {....}}
essentially create a graph of some triples queried.
I did not get back any results. I researched and understood that a SPARQL
query works over an RDF datasets which consists of 1 default graph and
multiple named graphs. I realized the mistake that the query was running
over a default graph which is empty, hence no results.
I rectifiied this by using the following API :
*Dataset ds = DatasetFactory.create(model);*
----model is the wrapped around the named graph.
and ran my sparql query over this and it worked beautifully. In this
approach, I could not figure out whether the triples were copied over to an
in memory model. It seemed it does not and query essentially runs against
the database. Would be great if someone that *confirm that.*
Now, the use case is the following: I want the SPARQL query to know its
graph and the graph is not set by Java code.
so the query is of the form:
CONSTRUCT {?x ?y ?z} FROM NAMED <graphname>
WHERE {SELECT {?x ?y ?z} WHERE {....}}
please note there is no FROM NAMED in the select clause below.
and I switch back to the old way of creating a dataset ----> *Dataset
dataset = DatasetStore.create(store);
*
Now the query executes but with no results.
I am not sure what did not work:
1. select clause does not return the correct result?
2. the dataset did not get assigned correctly, that is, the named graph was
not found in the store?
To check I tried to modify the query to :
CONSTRUCT {?x ?y ?z} FROM NAMED <graphname>
WHERE {SELECT {?x ?y ?z} FROM NAMED <graphname> WHERE {....}}
Now, it seems that named graphs are not supported for sub queries (checked
the code).
What is the best approach for such a scenario? or there is something that I
am missing?
Thanks a lot in advance.
Best Regards,
Ashish