Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

SPARQL Query Question

Hi All,
I'm using SPARQL with JFS Query and Indexing and I have a question about forming a SPARQL query. I
want to have a query that reports results that not only match a criteria, but are also missing a
field. For example, I might have an index that generates something like this:

<j>813f9e12-bbee-4013-a593-eeab8ccd08fc</j>

So my query would like (ignoring the PREFIX declarations) like this:

SELECT ?resource WHERE { ?resource j.2:poolId \"813f9e12-bbee-4013-a593-eeab8ccd08fc\" ;
j.2:commandLocator \"\" . }

However, that would not match, because there is no j.2:commandLocator in the index. I do want it to
match when the poolId is a certain value and there no entry for commandLocator in the index (because
there is no commandLocator). How can I do the second part?
Thanks in advance!

--Stephen

0 votes



One answer

Permanent link
Yes this is feasible using the bound Sparql function combined with OPTIONAL, see http://www.w3.org/TR/rdf-sparql-query/#func-bound for full details, but roughly you could write your query like:

SELECT ?resource 

WHERE {
?resource j.2:poolId "813f9e12-bbee-4013-a593-eeab8ccd08fc" .
OPTIONAL { ?resource j.2:commandLocator ?loc } .
FILTER ( !bound(?loc) )
}

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Nov 23 '09, 6:38 p.m.

Question was seen: 6,425 times

Last updated: Nov 23 '09, 6:38 p.m.

Confirmation Cancel Confirm