tags:

views:

300

answers:

1

I want to select a triple using SPARQL. To do it, i'm using following query:

SELECT count (*)
WHERE {?s ?p ?o}
FILTER (?s=http://kjkhlsa.net && ?p=http://lkasdjlkjas.com && ?o=Test)

As answer i get fully wrong triple :( subject ist not equal to "http://kjkhlsa.net", predicate is not equal to "http://lkasdjlkjas.com" and object ist also not equal to "Test". Can someone explain me, what I'm doing wrong :(

edit1: I have put the query into php file:

    $inst_query = 'SELECT * { <http://kjkhlsa.net&gt; <http://lkasdjlkjas.com&gt; "Test"}';
    echo $inst_query;

The answer from the echo was "SELECT * { "Test"}". Then i tried it with WHERE:

    $inst_query = 'SELECT * WHERE { <http://kjkhlsa.net&gt; <http://lkasdjlkjas.com&gt; "Test"}';
    echo $inst_query;

Here was the answer "SELECT * WHERE { "Test"}"...so, i'm missing the URIs, but this seems for me as php issue and not sparql problem.

edit2: I've put the query into SPARQL Query editor and i get the response "no result"....but I'm sure, that i have this triple.

+1  A: 

In its current form the question is not very clear (see my comment above).

Since you are essentially trying to get triples matching a pattern, it is more efficient to use a graph pattern instead of FILTER. Many SPARQL implementations first match candidate triples by graph patterns and only then apply the FILTER expression. In essence, with a ?s ?p ?o graph pattern, you're doing a linear scan over all your triples.

So, here's something that should work, using graph patterns instead of FILTER.

SELECT * { <http://kjkhlsa.net&gt; <http://lkasdjlkjas.com&gt; "Test" }

Notes: I didn't include COUNT(*) which is not standard SPARQL. <> around URIs. "" around literal.

laalto
i have tried it, but still doesnt work. I'm ure, I'm doing something wrong... but that is not the query. Thanks for the hint with <> and "". As soon as I solve the problem, I will post the solution here.
cupakob
You've added trailing slashes to the URIs Sirakov gave initially. So running the query you provided will not actually match what was intended since the URIs must match exactly.
Phil M
@Phil M: Ah, a feature of the browser URL copy-paste function. Thanks for pointing that out. I'll edit the answer.
laalto
@Sirakov: If it still doesn't work, please post additional details. Preferably by editing the original post.
laalto
It works, i need the "FROM"-Clause to specify which model must be used: SELECT * FROM MODEL_URI WHERE {<kjkhlsa.net> <lkasdjlkjas.com> "Test"}
cupakob