Here's an example I just tinkered with:

In RELS-EXT:
<rdf:description rdf:about="info:fedora/10783:GRSM00146">
<ar:litval>a literal value</ar:litval>
<ar:hasPrimaryCollection 
rdf:resource="info:fedora/USAR:CO_Resources"></ar:hasPrimaryCollection>
</rdf:description>

This query:
select ?sub ?pred ?obj
where
{
?sub ?pred ?obj.
filter (regex (?obj,"literal","i"))
}

will return this result:
<sub uri="info:fedora/10783:GRSM00146"/>
<pred uri="http://mita.clemson.edu/schemas/ar/1.0/ARSchema/litval"/>
<obj>a literal value</obj>

But this query:
select ?sub ?pred ?obj
where
{
?sub ?pred ?obj.
filter (regex (?obj,"Resources","i"))
}

will not return the <ar:hasPrimaryCollection> triple.

This query:
select ?sub ?pred ?obj
where
{
?sub ?pred ?obj.
filter (?sub = <info:fedora/10783:GRSM00146> && ?obj = 
<info:fedora/USAR:CO_Resources>)
}

will return the <ar:hasPrimaryCollection> triple.

So if the "resource" that is being related is a literal, you can use the 
REGEX. If it is not a literal, REGEX isn't the answer. I don't know how 
to do a wild card search in the latter case (if it is even possible with 
SPARQL).

I just wrestled with this same thing a week or so ago. I remember 
(vaguely -- a week is a long time :-)) concluding that it is not Fedora 
but the SPARQL specification that limits what REGEX can operate on. ITQL 
might be more flexible on this point, but I don't really know.

Scott

On 11/14/2011 09:18 AM, HIGGINS R.I. wrote:
> Does the REGEX function work with RELS-EXT in Fedora?
>
> Querying our risearch in Fedora 3.4.1, find tuples, with SPARQL
> outputting CSV thus
> ---------------
> select ?RefNo ?hasLocalReferenceNumber from<#ri>
> where {
> ?RefNo<fedora-rels-ext:hasLocalReferenceNumber>
> ?hasLocalReferenceNumber
> }
> ---------------
> returns
> ---------------
> <sparql><head><variable name="RefNo"/><variable
> name="hasLocalReferenceNumber"/></head>
> <results>
> <result><RefNo
> uri="info:fedora/UkDhU:c5c99db0-a962-4075-9e76-6441a728444f"/><hasLocalR
> eferenceNumber uri="UkDhU:SAD.204/4"/></result>
> <result><RefNo
> uri="info:fedora/UkDhU:abecf7d9-edbd-4d80-9243-182796d3a043"/><hasLocalR
> eferenceNumber uri="UkDhU:DCD.Misc.Ch.3650"/></result>
> </results>
> </sparql>
> or as CSV
> "RefNo","hasLocalReferenceNumber"
> info:fedora/UkDhU:c5c99db0-a962-4075-9e76-6441a728444f,UkDhU:SAD.204/4
> info:fedora/UkDhU:abecf7d9-edbd-4d80-9243-182796d3a043,UkDhU:DCD.Misc.Ch
> .3650
> --------------
> but
> -------------
> select ?RefNo ?hasLocalReferenceNumber from<#ri>
> where {
> ?RefNo<fedora-rels-ext:hasLocalReferenceNumber>
> ?hasLocalReferenceNumber .
> FILTER regex(?hasLocalReferenceNumber, "U", "i" )
> }
> -----------
> returns an empty
> -----------
> <sparql><head><variable name="RefNo"/><variable
> name="hasLocalReferenceNumber"/></head>
> <results>
> </results>
> </sparql>
> or as CSV
> "RefNo","hasLocalReferenceNumber"
> ------------
>
> Now, is this because you can only have URIs in rels-ext values and
> SPARQLs regex doesn't works with URIs? If that is so, presumably you
> cannot use regex in Fedora? And I need Yet Another Datastream instead of
> this more succinct solution?
> Sorry for the long email.
> - - - - -
> # Richard Higgins
> # Durham University Library
> # Archives&  Special Collections
> # Palace Green
> # Durham
> # DH1 3RN
> # E-Mail: r.i.higg...@durham.ac.uk
>
>
> -----Original Message-----
> From: Scott Hammel [mailto:sc...@clemson.edu]
> Sent: 11 November 2011 14:10
> To: Support and info exchange list for Fedora users.
> Subject: Re: [fcrepo-user] Wild card searching of Resource Index
>
> I use the REGEX function in SPARQL through Fedora's RI search service
> successfully. It won't work, though, if the value is an IRI and not a
> literal -- but I'm a fairly novice SPARQLer myself, so others can
> correct or confirm that.
>
> scott
>
> On 11/11/2011 08:40 AM, Benjamin Armintor wrote:
>> You might also try using the REGEX function in a SPARQL query.  I'm
>> not sure if Fedora will pass it along to Mulgara or not, but it's
>> worth a shot.
>>
>> On Fri, Nov 11, 2011 at 8:32 AM,<aj...@virginia.edu>   wrote:
>>> It sounds a bit like you're using the RI (an RDF index) to do
> something (string-matching) at which a full-text index (like Lucene or
> Zebra) would be better.
>>> If you want to use RDF for this problem, I suggest that you create
> objects to represent those upper entities you named (building,
> collection, section, etc) and make a graph, e.g.
>>> objects:myobject1 isMemberOf sections:UkDhU.DCD.Misc.Ch
>>> objects:myobject2 isMemberOf sections:UkDhU.DCD.Misc.Ch
>>> sections:UkDhU.DCD.Misc.Ch isPartOf collections:UkDhU.DCD
>>> collections:UkDhU.DCD isInside buildings:UkDhU
>>>
>>> or using some other suitable RDF predicates. Then your query will not
> rely on string-matching, at which RDF stores are not especially good,
> but on structure matching, at which RDF stores are very good. In my
> example a query to find the object in a building might look something
> like:
>>> SELECT
>>>    ?object isInside ?building
>>> WHERE {
>>>    ?object isMemberOf ?section.
>>>    ?section isPartOf ?collection.
>>>    ?collection isInside ?building.
>>> }
>>>
>>> or to find how many objects from a collection have been Fedora-ized,
> you could use a count query on:
>>> SELECT
>>>    ?object
>>> WHERE {
>>>    ?object isMemberOf ?section.
>>>    ?section isPartOf ?collection.
>>> }
>>>
>>> and so forth.
>>>
>>>
>>> ---
>>> A. Soroka
>>> Online Library Environment
>>> the University of Virginia Library
>>>
>>>
>>>
>>>
>>> On Nov 11, 2011, at 7:50 AM, HIGGINS R.I. wrote:
>>>
>>>> Hello:
>>>> I am attempting to keep track of which of our real objects have
> digital
>>>> versions stored in Fedora. The simplest way to do this seemed to be
> to
>>>> add an entry to the RELS-EXT datastream along the lines of
>>>>
>>>> <hasLocalReferenceNumber
>>>> xmlns="info:fedora/fedora-system:def/relations-external#"
>>>> rdf:resource="UkDhU:DCD.Misc.Ch.3650"></hasLocalReferenceNumber>
>>>>
>>>> For this to be useful, it would be necessary to be able to different
>>>> searches:
>>>> find all starting UkDhU:* (everything in the building)
>>>> find all starting UkDhU:DCD* (everything in the collection)
>>>> find all starting UkDhU:DCD.Misc.Ch.* (everything in the section of
> the
>>>> collection)
>>>> and so forth - assuming * to be a wild card.
>>>>
>>>> The lack of information on wild card searching of RDF out there
> implies
>>>> that this is not a feature that is available. Is there a way to do
> this,
>>>> or is it back to the drawing board ?
>>>> Thank you
>>>> - - - - -
>>>> # Richard Higgins
>>>> # Durham University Library
>>>> # Archives&   Special Collections
>>>> # Palace Green
>>>> # Durham
>>>> # DH1 3RN
>>>> # E-Mail: r.i.higg...@durham.ac.uk
>>>>
>>>>
>>>>
> ------------------------------------------------------------------------
> ------
>>>> RSA(R) Conference 2012
>>>> Save $700 by Nov 18
>>>> Register now
>>>> http://p.sf.net/sfu/rsa-sfdev2dev1
>>>> _______________________________________________
>>>> Fedora-commons-users mailing list
>>>> Fedora-commons-users@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/fedora-commons-users
>>>
> ------------------------------------------------------------------------
> ------
>>> RSA(R) Conference 2012
>>> Save $700 by Nov 18
>>> Register now
>>> http://p.sf.net/sfu/rsa-sfdev2dev1
>>> _______________________________________________
>>> Fedora-commons-users mailing list
>>> Fedora-commons-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/fedora-commons-users
>>>
> ------------------------------------------------------------------------
> ------
>> RSA(R) Conference 2012
>> Save $700 by Nov 18
>> Register now
>> http://p.sf.net/sfu/rsa-sfdev2dev1
>> _______________________________________________
>> Fedora-commons-users mailing list
>> Fedora-commons-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/fedora-commons-users
>>
>


-- 
CCIT
Clemson University
864-656-8118
Free/Busy Calendar: http://bit.ly/dBeBzo


------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Fedora-commons-users mailing list
Fedora-commons-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fedora-commons-users

Reply via email to