I’m trying to understand how to construct a REST request for retrieving items based on a RDF property. Until today I have managed to cover my use cases using search without specifying the exact search criteria. String search using REST is easy (eg. http://myomekasite.example/api/items?search=mysearchstring works fine), but I’m struggling to understand, how to construct a RDF property search. So far, my attempts have failed. I tried the following (based on the documentation) – but apparently I have misunderstood how to construct a proper request
The trick is at the beginning of that section: property
is an array of criteria, each of which it itself an array/hash with the specified subkeys. So, you don’t set type, text, etc. directly on property, but on a subarray:
property[0][property]=11&property[0][type]=eq&property[text]=teststring
If you’re starting from PHP code, it’s the query string serialization of an array like this:
[
'property' => [
[
'property' => 11,
'type' => 'eq',
'text' => 'teststring',
],
],
]
The “extra” array level is there to allow for multiple queries at once on different (or the same) properties.
Thanks! I tried the subarray syntax but it seems that the query still returns items which are not having the queried value in defined property.
For an example this request:
http://expo.oscapps.jyu.fi/api/items?property[0][property]=2&property[0][type]=in&property[text]=Kinnunen
returns 75 items, even though in the database, there is only one item which has dcterms:creator containing the queried string.
You missed the [0]
on your last parameter there, the actual search string.
Ah, I should have been more careful. Thanks for help!