simple query question

0 views
Skip to first unread message

andrew....@elucidbio.com

unread,
Apr 20, 2016, 9:21:08 AM4/20/16
to Stardog
hello,
the following query gets me all of my "readings" instances. How do I extend it to specify all readings with name "elucid:MaxThickness"? (name is a property).  (I know the question is trivial, thank you for bearing with folks on a learning curve.)

@
select ?s ?p (<http://elucidbio.com/kb/Reading> as ?o) ?g {
  { ?s ?p <http://elucidbio.com/kb/Reading> }
union
  { graph ?g { ?s ?p <http://elucidbio.com/kb/Reading> } }
}
@

Thank you,
Andy

Pavel Klinov

unread,
Apr 20, 2016, 9:27:31 AM4/20/16
to sta...@clarkparsia.com
Hi Andy,

In the same way as you specified elucid:reading as your object: sub ?p by the IRI in both triple patterns, add (elucid:reading as ?p) to the projection, and don't forget to declare the namespace prefix elucid:

Cheers,
Pavel

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

Andrew J. Buckler (Elucid Bioimaging)

unread,
Apr 20, 2016, 9:32:14 AM4/20/16
to sta...@clarkparsia.com


Thank you Pavel, please corretc my syntax?  I tried a number of variatiosn but do not yet have it right.


select (<http://elucidbio.com/kb/85988275215718899248> as ?s) WHERE name elucid:MaxThickness ?g {
  { <http://elucidbio.com/kb/85988275215718899248> WHERE name elucid:MaxThickness }
union
  { graph ?g { <http://elucidbio.com/kb/85988275215718899248> WHERE name elucid:MaxThickness } }
}



From: Pavel Klinov <pa...@clarkparsia.com>
Sent: Wednesday, April 20, 2016 9:27 AM
To: sta...@clarkparsia.com
Subject: Re: [stardog-users] simple query question
 
---
You received this message because you are subscribed to a topic in the Google Groups "Stardog" group.
To unsubscribe from this topic, visit https://groups.google.com/a/clarkparsia.com/d/topic/stardog/7RV2EPOvk5c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stardog+u...@clarkparsia.com.

Pavel Klinov

unread,
Apr 20, 2016, 9:47:01 AM4/20/16
to sta...@clarkparsia.com
PREFIX elucid:  <http://elucidbio.com/kb/>

select ?s (elucid:MaxThickness as ?p) (<http://elucidbio.com/kb/Reading> as ?o) ?g { 
  { ?s elucid:MaxThickness <http://elucidbio.com/kb/Reading> } 
union 
  { graph ?g { ?s elucid:MaxThickness <http://elucidbio.com/kb/Reading> } } 
}

Andrew J. Buckler (Elucid Bioimaging)

unread,
Apr 20, 2016, 9:55:10 AM4/20/16
to sta...@clarkparsia.com

Ok; the following gets nothing back.  “name” is a property, “elucid:MaxThickness” is a value for that property.  Not a predicate, as this syntax implies?  In other words, I want the subset of readings that have the specific name.

Pavel Klinov

unread,
Apr 20, 2016, 10:07:42 AM4/20/16
to sta...@clarkparsia.com
OK, I didn't realize "name" is the name of a property. 

How's your data modeled? Can you show a couple of triples for a particular reading? Normally I'd expect something like:

elucid:reading_1 rdf:type elucid:Reading .
elucid:reading_1 elucid:name elucid:MaxThickness

Then the query pattern would be: 

?reading a elucid:Reading ; 
               elucid:name elucid:MaxThickness .

Also note that since you only have a single named graph, and you know its IRI, your query can be simplified to:

SELECT * WHERE {
  graph <elucid:your-graph> {
    ?reading a elucid:Reading ; 
                   elucid:name elucid:MaxThickness . 
  }
}

Cheers,
Pavel

Andrew J. Buckler (Elucid Bioimaging)

unread,
Apr 20, 2016, 10:20:38 AM4/20/16
to sta...@clarkparsia.com

Yes, that did it Pavel.  Thank you.

Reply all
Reply to author
Forward
0 new messages