Hi folks,
I am having trouble with unexpected SPARQL query results that use FILTER. I am using Stardog 7.04 on Windows OS.
I am constructing to query to find Subjects that have the exact same "set" of triples. In this example data, :Set2
should be identified as the only exact match with :Set1
, while :Set1
and :Set3
are NOT an exact match because of the value :VAL_E
.
@prefix : <https://www.example.org/Eg#>.
:Set1 :hasValue :VAL_A, :VAL_B, :VAL_C, :VAL_D .
:Set2 :hasValue :VAL_A, :VAL_B, :VAL_C, :VAL_D .
:Set3 :hasValue :VAL_A, :VAL_B, :VAL_C, :VAL_D, :VAL_E .
:Set4 :hasValue :VAL_A, :VAL_B .
:Set5 :hasValue :VAL_F, :VAL_G, :VAL_H, :VAL_I, :VAL_J .
I am told this query returns the correct result of :Set1, :Set2 when executed on Apache Jena Fuseki and on Ontotext GraphDB.
PREFIX : <https://www.example.org/Eg#>
SELECT DISTINCT ?s1 ?s2 {
?s1 ?p ?o .
?s2 ?p ?o .
FILTER NOT EXISTS { ?s1 ?p1 ?o1 . FILTER NOT EXISTS { ?s2 ?p1 ?o1 } }
FILTER NOT EXISTS { ?s2 ?p2 ?o2 . FILTER NOT EXISTS { ?s1 ?p2 ?o2 } }
FILTER (STR(?s1) < STR(?s2))
}
But in Stardog Studio, I get:
:Set1 :Set2
:Set2 :Set4
:Set1 :Set4
:Set3 :Set4
:Set2 :Set3
:Set1 :Set3
Similarly, I want to find "What subject in the data has an identical set of P,O to :Set1? The answer should be :Set2 and only :Set2. But when I run this query:
PREFIX : <https://www.example.org/Eg#>
SELECT DISTINCT ?s2 {
:Set1 ?p ?o .
?s2 ?p ?o .
FILTER NOT EXISTS { :Set1 ?p1 ?o1 . FILTER NOT EXISTS { ?s2 ?p1 ?o1 } }
FILTER NOT EXISTS { ?s2 ?p2 ?o2 . FILTER NOT EXISTS { :Set1 ?p2 ?o2 } } # omit match from :Set3 to :Set1
FILTER (STR(:Set1) < STR(?s2))
}
I get the result:
:Set2
:Set4
What is :Set4 present? I posted this question on StackOverflow which is where I was told expected result of only :Set2 is present for Fuseki and GraphDB.
Thanks for your help!
Tim