Itql scripts

From Devwiki
Jump to: navigation, search

Normal ITQL Queries

Find Members of Collection

The following query finds object which have the 'isMemberOf' relationship to the colleciton 'collection:digitisation'

 select $member from <#ri> where $member <fedora-rels-ext:isMemberOf> <info:fedora/collection:digitisation>

When the return format is set to CSV the output will be:


Find Members of Collection and print dc:title

The following query finds objects which have a 'isMemberOf' relationship to he collection 'collection:digitisation' and displays the PID and title.

 select $member $title from <#ri> where 
                                 $member <fedora-rels-ext:isMemberOf> <info:fedora/collection:digitisation> and
                                 $member <dc:title> $title

When the return format is set to CSV the output will be:

 info:fedora/llgc-id:183,"[Revd D Williams, Llangollen] [graphic]."
 info:fedora/llgc-id:226,"[Revd J B Thomas and Mrs Thomas and family, St Clears] [graphic]."
 info:fedora/llgc-id:108,[A view of Nefyn from Holburn] [graphic].
 info:fedora/llgc-id:196,"[Revd W Pierce, Rhosemor] [graphic]."
 info:fedora/llgc-id:182,"[Revd David Williams, Llangollen (CM)] [graphic]."
 info:fedora/llgc-id:221,[Revd Richards] [graphic].
 info:fedora/llgc-id:178,[Revd W Jones (1889)] [graphic].
 info:fedora/llgc-id:150,"[Revd D Williams, Penmorfa] [graphic]."
 info:fedora/llgc-id:215,"[Revd W Jones, Llanfair Caereinion (MC)] [graphic]."
 info:fedora/llgc-id:225,[Revd T Roberts] [graphic].

Find Property

If you added a property to the FOXML before ingest e.g.:

       <foxml:property NAME="" VALUE="FedoraObject"/>
       <foxml:property NAME="info:fedora/fedora-system:def/model#state" VALUE="Active"/>
       <foxml:property NAME="info:fedora/fedora-system:def/model#label" VALUE="Chapel Street, Oswestry, Methodist Church Autumn Fair"/>
       <foxml:property NAME="info:fedora/fedora-system:def/model#createdDate" VALUE="2007-10-23T12:00:37.088Z"/>
       <foxml:property NAME="info:fedora/fedora-system:def/view#lastModifiedDate" VALUE="2007-10-23T12:00:37.166Z"/>
       <foxml:property NAME="info:fedora/fedora-system:def/model#contentModel" VALUE="METS-VITAL02"/>
       <foxml:extproperty NAME="" VALUE="10107/34753"/>
       <foxml:extproperty NAME="" VALUE=""/>
       <foxml:extproperty NAME="" VALUE="WlAbNL003368990"/>
       <foxml:extproperty NAME="" VALUE="(WlAbNL)003368990"/>

You can search these values using the following query

   select $object from <#ri> where $object <> 'WlAbNL003368990'

Where is the name of a property and 'WlAbNL003368990' is the value.

Find Gutor Glyn manuscripts and show the children associated with the manuscript

 select $member $child from <#ri> where 
     $member <fedora-rels-ext:isMemberOfCollection> <info:fedora/collection:gutorglyn> and 
     $member <fedora-model:hasModel> <info:fedora/model:parent> and
     $child <fedora-rels-ext:isPartOf> $member

Full Text Queries

For the following queries to work you need to change the auto full text property of the kowari configuration to true. Extract of fedora.conf is below:

 <datastore id="localKowariTriplestore">
   <comment>local Kowari Triplestore used by the Resource Index</comment>
   <param name="connectorClassName" value="org.trippi.impl.kowari.KowariConnector"/>
   <param name="remote" value="false"/>
   <param name="path" value="/home/fedora/version2.1.1/resourceIndex" isFilePath="true"/>
   <param name="serverName" value="fedora"/>
   <param name="modelName" value="ri"/>
   <param name="poolInitialSize" value="3"/>
   <param name="poolMaxGrowth" value="-1"/>
   <param name="readOnly" value="false"/>
   <param name="autoCreate" value="true"/>
   <param name="autoTextIndex" value="true"/> 
   <param name="memoryBuffer" value="true"/>
   <param name="autoFlushDormantSeconds" value="5"/>
   <param name="autoFlushBufferSize" value="20000"/>
   <param name="bufferFlushBatchSize" value="20000"/>
   <param name="bufferSafeCapacity" value="40000"/>

Then stop fedora and run fedora-rebuild from $FEDORA_HOME/server/bin. Select option 1 to rebuild the resource index. Then start fedora again.

Search DC in Collection

This query selects all objects with 'aberystwyth' in the dublin core title field in the collection with pid 'collection:jth':

 select $member subquery(select $member from <#ri> where
                        $member <fedora-rels-ext:isMemberOf> <info:fedora/collection:jth>) 
                   from <#ri-fullText> where $member <> 'aberystwyth'

When the return format is set to CSV the output will be:


I think the null,null is because there is an object with 'aberystwyth' in the dublin core title field but it is not part of the collection 'collection:jth'.