You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Thorben Wallmeyer <tw...@yahoo.de> on 2014/06/23 14:11:00 UTC

SPARQL Describe query

Hi all,

I've got a model/graph that I would like to query. All I do is executing 
the query "DESCRIBE <MY_NS://knowledge/my_resource>". This returns me 
all statements that use the named resource as subject. What do I have to 
do, to get all statements that use this resource as object, too? How 
does the query has to look like? Everything i tried did not have the 
expected effect.


Can you give me a hint?


Thanks in advance,

Thorben

Re: SPARQL Describe query

Posted by Stephen Allen <sa...@apache.org>.
Small performance note, you should use a union in the where clause to
prevent a Cartesian product:

CONSTRUCT {
  <MY_NS://knowledge/my_resource> ?p1 ?o1 .
  ?s2 ?p2 <MY_NS://knowledge/my_resource> .
}
WHERE {
  { <MY_NS://knowledge/my_resource> ?p1 ?o1 . }
  union
  { ?s2 ?p2 <MY_NS://knowledge/my_resource>  . }
}

-Stephen

On Mon, Jun 23, 2014 at 8:45 AM, Bob DuCharme <bo...@snee.com> wrote:

> The SPARQL spec is a bit vague on what DESCRIBE should return ("The RDF
> returned is determined by the information publisher"), which is why some
> endpoints return only the triples that have that resource as a subject, and
> others also return triples that have that as a subject. The simplest way to
> get exactly the triples you want is to specify them with a CONSTRUCT query
> like this:
>
> CONSTRUCT {
>   <MY_NS://knowledge/my_resource> ?p1 ?o1 .
>   ?s2 ?p2 <MY_NS://knowledge/my_resource>  .
> }
> WHERE {
>   <MY_NS://knowledge/my_resource> ?p1 ?o1 .
>   ?s2 ?p2 <MY_NS://knowledge/my_resource>  .
> }
>
> Bob DuCharme
> learningsparql.com
>
>
> On 6/23/2014 8:11 AM, Thorben Wallmeyer wrote:
>
>> Hi all,
>>
>> I've got a model/graph that I would like to query. All I do is executing
>> the query "DESCRIBE <MY_NS://knowledge/my_resource>". This returns me
>> all statements that use the named resource as subject. What do I have to
>> do, to get all statements that use this resource as object, too? How does
>> the query has to look like? Everything i tried did not have the expected
>> effect.
>>
>>
>> Can you give me a hint?
>>
>>
>> Thanks in advance,
>>
>> Thorben
>>
>>
>

Re: SPARQL Describe query

Posted by Bob DuCharme <bo...@snee.com>.
The SPARQL spec is a bit vague on what DESCRIBE should return ("The RDF 
returned is determined by the information publisher"), which is why some 
endpoints return only the triples that have that resource as a subject, 
and others also return triples that have that as a subject. The simplest 
way to get exactly the triples you want is to specify them with a 
CONSTRUCT query like this:

CONSTRUCT {
   <MY_NS://knowledge/my_resource> ?p1 ?o1 .
   ?s2 ?p2 <MY_NS://knowledge/my_resource>  .
}
WHERE {
   <MY_NS://knowledge/my_resource> ?p1 ?o1 .
   ?s2 ?p2 <MY_NS://knowledge/my_resource>  .
}

Bob DuCharme
learningsparql.com

On 6/23/2014 8:11 AM, Thorben Wallmeyer wrote:
> Hi all,
>
> I've got a model/graph that I would like to query. All I do is 
> executing the query "DESCRIBE <MY_NS://knowledge/my_resource>". This 
> returns me all statements that use the named resource as subject. What 
> do I have to do, to get all statements that use this resource as 
> object, too? How does the query has to look like? Everything i tried 
> did not have the expected effect.
>
>
> Can you give me a hint?
>
>
> Thanks in advance,
>
> Thorben
>


Re: SPARQL Describe query

Posted by Thorben Wallmeyer <tw...@yahoo.de>.
Hi Chris,

can you give me an example construct query that does the job?


Best,

Thorben

Am 23.06.2014 14:42, schrieb Chris Dollin:
> On Monday, June 23, 2014 02:11:00 PM Thorben Wallmeyer wrote:
>
>> I've got a model/graph that I would like to query. All I do is executing
>> the query "DESCRIBE <MY_NS://knowledge/my_resource>". This returns me
>> all statements that use the named resource as subject.
> More than that -- it typically does bnode closure, so eg if the
> value of some property is a list you get the entire list structure.
>
>> What do I have to
>> do, to get all statements that use this resource as object, too?
> Write an explicit CONSTRUCT query that has that resource as an object
> of some triples.
>
>> How does the query has to look like? Everything i tried did not have the
>> expected effect.
> What did you try? What did you get?
>
> Chris
>


Re: SPARQL Describe query

Posted by Chris Dollin <ch...@epimorphics.com>.
On Monday, June 23, 2014 02:11:00 PM Thorben Wallmeyer wrote:

> I've got a model/graph that I would like to query. All I do is executing 
> the query "DESCRIBE <MY_NS://knowledge/my_resource>". This returns me 
> all statements that use the named resource as subject.

More than that -- it typically does bnode closure, so eg if the
value of some property is a list you get the entire list structure.

> What do I have to 
> do, to get all statements that use this resource as object, too? 

Write an explicit CONSTRUCT query that has that resource as an object
of some triples.

> How does the query has to look like? Everything i tried did not have the 
> expected effect.

What did you try? What did you get?

Chris

-- 
"A facility for quotation covers the absence of original thought."/Gaudy Night/

Epimorphics Ltd, http://www.epimorphics.com
Registered address: Court Lodge, 105 High Street, Portishead, Bristol BS20 6PT
Epimorphics Ltd. is a limited company registered in England (number 7016688)