2

Suppose I have a RDF-base containing 4 triples:

"John"  "loves" "sushi"
"John"  "loves" "Mary"
"Frank" "hates" "sushi"
"John"  "hates" "olives"

and let's say I consider "sushi" such a weird thing that I'd like to know what exactly people can do with it and even more what else they can apply the same action to =)

So I write a SPARQL query that seems logical to me:

SELECT ?s ?o WHERE
{
  ?s ?p "sushi".
  ?s ?p ?o
}

naturally expecting to get the following result

"John"  "sushi"
"John"  "Mary"
"Frank" "sushi"

because for each of the first 3 triples there exists a satisfying pair of (?s, ?p) values that makes the joined pattern evaluate to TRUE.

But in reality (I use local 4store engine & DB) the answer is like this:

"John"  "sushi"
"John"  "Mary"
"Frank" "sushi"
"John"  "olives"

Can someone explain this behavior to me?

And if this is truly how it should work in SPARQL, then what is the way to get what I need?

  • Not having used sparql, this seems incredibly arbitrary to me. What is so special about `John hates olives` that makes you think it should be rejected? – Blindy Aug 17 '11 at 14:51
  • 1
    You see, if s="John" and p="hates" there's no such triple in the database that satisfies the first part of the query. And I would expect this part to **define** my area of interest. I would like to find what other things John may love if he loves sushi, or what other things he may hate if he hates sushi. But what I get is a mix -- Frank hates sushi and because of that I'm doomed to be told what John hates also. – Anton Zherzdev Aug 17 '11 at 15:01
  • How odd. Again, I can't help you, I was just curious about it :) – Blindy Aug 17 '11 at 15:04

1 Answers1

1

Hmmm, this looks like it may be a bug in 4store since I've just tested this in four different independent SPARQL implementations - Jena ARQ, dotNetRDF Leviathan, OpenLink Virtuoso and Clark & Parsia's Stardog - and they all return the answer you were expecting.

And as a self confessed SPARQL nut I think the answer you are expecting is the correct one.

I'd suggest getting in touch with the 4store guys using their support mailing list - http://groups.google.com/group/4store-support?pli=1

Note this may not be a bug directly in 4store but a bug in the underlying rasqal query library but I don't know enough about 4store to tell you one way or another.

RobV
  • 28,022
  • 11
  • 77
  • 119
  • 2
    4store has it's own query engine, so if the a bug it will be in that. I can imagine what the bug is, the optimiser is probably disregarding ?p as it's apparently not important to the query, but infact it needs the value. – Steve Harris Aug 17 '11 at 15:09
  • Thanks a lot, RobV. I will check one of the implementations you mentioned. Good to know I'm not mad =) – Anton Zherzdev Aug 17 '11 at 15:13
  • 1
    **Update:** Bug in 4store has been fixed. Fix should appear in version 1.1.4. – Anton Zherzdev Aug 26 '11 at 14:10