I use sesame2 with a Posgresql sail. I am looking for a query in SERQL, which let me find the lowest common ancestor (in a tree) of two concept A and B. I don't know how many levels I have above A and B. A and B are linked by predicate "parent_category".
What you need for this to work is support for querying property paths (as is being specified in the current SPARQL 1.1 Query working draft). Sesame, unfortunately, does not support this yet (note that SPARQL 1.1 is not yet supported by Sesame, it's being worked on though, planned for release 2.4).
However, a way around this is to make use of reasoning and define your property "parent_category" as a transitive property. This can be done in roughly three ways in Sesame (listed from dirtiest to cleanest solution ;) ):
Once you have defined your property as transitive, you can then use this query for the lowest common ancestor (in SeRQL):
(note: if you use option 1, you will have to query for rdfs:subClassOf properties instead of ex:parent_category properties).
answered 10 Feb '11, 20:22
Jeen Broekstra ♦
Jeen, that was kind of funny. As you wrote about SparQL 1.1, i imagined the openrdf issue navigator, where one may find the current status of a development process (i am not expaining that for you...). I changed there with the plan, to post this link here. I had to smile a bit, but maybe i'll let the people just explore themselfes :)
Wanna have the current status of sesame supporting sparql 1.1? Please look at
cheers josh and thanks Jeen. I am hot for this feature.
answered 11 Feb '11, 14:37