Child pages
  • Fedora Resource Index

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Corrected links that should have been relative instead of absolute.

The ResourceIndex manages relationships between Fedora objects. It is very powerful, but the query syntax can be tricky.

Sample RIsearch queries

Select objects, modification dates, and titles. Start with the 50th Fedora object, and get the next 25 objects:

No Format
select     $object $modified $title $type
from       <#ri>
where      $object <rdf:type> $type
and        $object <rdf:type> <fedora-model:FedoraObject>
and        $object <fedora-view:lastModifiedDate> $modified
and        $object <dc:title> $title
order by   $title $object
limit      25
offset     50

Count all objects that are members of the collection object iudl:10:

No Format
select count(
  select  $object
  from    <#ri>
  where   $object
          <info:fedora/fedora-system:def/relations-external#isMemberOfCollection>
          <info:fedora/iudl:10>
  )
from <#ri>
where $a $b $c

Get all collection objects:

No Format
select  $object
from    <#ri>
where   $object
        <fedora-model:hasModel>
        <info:fedora/cmodel:collection>

Get the status of the OVERVIEW datastream:

No Format
select  $state
from    <#ri>
where   <info:fedora/iudl:99732/OVERVIEW>
        <fedora-model:state>
        $state

Find all inactive items:

No Format
select  $object
from    <#ri>
where   $object
        <fedora-model:state>
        <info:fedora/fedora-system:def/model#Inactive>

Find the OwnerID for an item:

No Format
select  $ownerId
from    <#ri>
where   <info:fedora/iudl:200332>
        <info:fedora/fedora-system:def/model#ownerId>
        $ownerId

Count all non-deleted items in a collection:

No Format
select count(select  $object
from    <#ri>
where $object
    <info:fedora/fedora-system:def/relations-external#isMemberOfCollection>
    <info:fedora/iudl:10>
minus $object
        <fedora-model:state>
        <info:fedora/fedora-system:def/model#Deleted>)
from <#ri>
where $a $b $c

Find all Service Deployments

No Format
select $object from <#ri>
where  $object <fedora-model:hasModel> <info:fedora/fedora-system:ServiceDeployment-3.0>

Find all Service Deployments for a given content model (in this case, the cmodel:image content model):

No Format
select $object from <#ri>
where  $object <fedora-model:isContractorOf> <info:fedora/cmodel:image>

Find all deleted object:

No Format
select  $object
from    <#ri>
where   $object <fedora-model:state> <info:fedora/fedora-system:def/model#Deleted>

Find all collections that have an item exposed through OAI PMH: (NOTE: be sure to check "Force Distinct")

No Format
select $collectionPid
from   <#ri>
where  $item           <http://www.openarchives.org/OAI/2.0/itemID> $itemID
and    $item           <info:fedora/fedora-system:def/relations-external#isMemberOfCollection>
 $collectionPid

Find all image-derivative items in the slocum collection that aren't described by another object nor contain description themselves

No Format
select $image
from <#ri>
where $image <fedora-model:hasModel> <info:fedora/cmodel:image-derivatives>
and $image <info:fedora/fedora-system:def/relations-external#isMemberOfCollection>
 <info:fedora/iudl:14>
minus $image
 <info:fedora/fedora-system:def/relations-external#hasMetadata>
 $description
minus $image <fedora-model:hasModel> <info:fedora/cmodel:item-metadata>

Find all service definitions that aren't registered with a "hasService" relationship to another object.

No Format
select $object from <#ri>
where $object <fedora-model:hasModel> <info:fedora/fedora-system:ServiceDefinition-3.0>
minus $object2 <fedora-model:hasService> $object

 

Encoding queries as URLs

All RI queries must be URL-encoded (with a tool like this one) before being added to a behavior mechanism. To manually encode a query, make the following substitutions:

Original

Replaced

#

%23

$

%24

(

%28

)

%29

/

%2F

:

%3A

<

%3C

>

%3E

[space]

+

Do not encode the parentheses around any parameters that you want Fedora to pass in. The encoded query should be placed after a suitable base URL like

No Format
http://fedora.dlib.indiana.edu/fedora/risearch?type=tuples&lang=itql&format=Sparql&query=

If no datastream parameters are being passed, remember to include a "nullbind" parameter (see Behavior Mechanisms for more detail on this). Here is a completed query that searches for the pages of a given object (linebreaks added for readability):

No Format
http://fedora.dlib.indiana.edu/fedora/risearch?type=tuples&lang=itql&format=Sparql&query=select+%24page+
%24sequence+from+%3C%23ri%3E+where+%24page+%3Cinfo%3Afedora%2Ffedora-system%3Adef%2Frelations-external%23
isPartOf%3E+%3C(objuri)%3E+and+%24page+%3Chttp%3A%2F%2Fdlib.indiana.edu%2Flib%2Fxml%2Finfrastructure%2F
rdfRelations%23sequenceNumber%3E+%24sequence&dummy=(NULLBIND)