SPARQL query: using embedded VALUES or UNION data with bigdata storage

I have a dataset that looks a bit like:

<item1> <isLocated> <someAddress> <item2> <isLocated> <someAddress> <item3> <isLocated> <someOtherAddress> 

I want to be able to use SPARQL to answer the question:

"What items will I find in someAddress or someOtherAddress?"

I could use UNION as follows:

 SELECT ?item { { ?item <isLocated> <someAddress> } UNION { ?item <isLocated> <someOtherAddress } } 

But I think it will get pretty dirty when I start talking about 100 or 1000 addresses.

I think VALUES embedded data might be more appropriate than a bunch of UNION queries. I tried writing the following query, but my RDF repository / engine (bigdata) seems to strangle it:

 SELECT ?item { ?item <isLocated> ?loc . } VALUES (?loc) { (<someAddress>) (<someOtherAddress>) } 

(based on http://www.w3.org/TR/sparql11-query/#inline-data )

The error I get from bigdata: Lexical error in row 5, column 7. Found: "(32), after:" VALUES "

Am I generating this request correctly? Is using UNION or VALUES more appropriate?

It seems that no matter how I format this request (based on the w3 examples in the link above), I get similar lexical errors.

Any ideas?

Greetings.

+4
source share
2 answers

Under the assumption, I would say that Bigdata does not yet support the VALUES clause. This is a new feature introduced in the latest SPARQL working draft (published just a few weeks ago), so it’s natural that several tools will not yet support it.

Instead, you can try using BINDINGS (this is about the same function from previous working drafts that has been replaced).

+5
source

You have mixed up the syntax a bit. Or use:

 VALUES ?loc { <someAddress> <someOtherAddress> } 

which is a special form for a single variable or:

 VALUES (?loc) { ( <someAddress> ) ( <someOtherAddress> ) } 

general form.

You can also try IN

 FILTER (?loc IN ( val1, val2, ...)) 
+3
source

Source: https://habr.com/ru/post/1435211/


All Articles