[xquery-talk] making a search case-insensitive
Cindy Girard
clm6u at virginia.edu
Thu Jul 27 09:35:25 PDT 2006
Thanks, Michael.
contains(upper-case($text), upper-case($keyword))
worked great!
MK> The correct way to do this is to search using a caseblind collation, but
MK> I've no idea whether that's a feature that your product supports.
MK> $keyword and upper-case($keyword) are both strings; you can't apply the "or"
MK> operator to two strings, it works only with boolean operands. So "$keyword
MK> or upper-case($keyword)" will give you a type error.
MK> Similarly, te contains() function tests whether one string is a substring of
MK> another. I suspect when you write contains($text, $kwds) you are imagining
MK> that $kwds is a set of strings and that the function will return true if
MK> $text contains any of them.
MK> So:
MK> (a) to make $kwds be a set (sequence) of strings, do
MK> $kwds := ($keyword, upper-case($keyword),
MK> lower-case($keyword), $mixedkwd)
MK> (b) to test if $text contains any of them, do
MK> some $k in $kwds satisfies contains($text, $k)
MK> But wouldn't it be easier simply to test
MK> contains(upper-case($text), upper-case($keyword))
MK> ?
MK> Michael Kay
MK> http://www.saxonica.com/
>> -----Original Message-----
>> From: talk-bounces at xquery.com
>> [mailto:talk-bounces at xquery.com] On Behalf Of Cindy Girard
>> Sent: 27 July 2006 02:18
>> To: talk at xquery.com
>> Subject: [xquery-talk] making a search case-insensitive
>>
>> Hi,
>>
>> I'm using Berkely XMLDB as my search database for one of my
>> projects, and I can't seem to find anything that allows me to
>> specify if I want the search case-sensitive or not. And it's
>> case-sensitive by default.
>>
>> Well, I need it to be case-insensitive, so I'm trying to do it in
>> the xquery instead.
>>
>> I have the following snippet:
>>
>> let $mixedkwd := (concat (upper-case(substring($keyword, 1,
>> 1)), lower-case(substring($keyword, 2)))),
>> $kwds := ($keyword or upper-case($keyword) or
>> lower-case($keyword) or $mixedkwd),
>>
>> $hits :=
>> for $entries in collection($collctn)//tei.2
>> let $docname :=
>> concat($entries/@id, '.xml')
>> let $text := $entries/text
>> where contains($text, $kwds)
>>
>>
>>
>>
>> I'm getting an ItemType matching failed error. Can someone correct
>> my syntax, or is there a better way to do this?
>>
>> Thanks,
>>
>> -----
>> - Cindy
>>
>> Cynthia M. Girard
>> IATH, University of Virginia
>> clm6u at virginia.edu
>>
>> "Danger? I laugh in the face of danger!
>> ...and then I hide until it goes away."
>>
>> _______________________________________________
>> talk at xquery.com
>> http://xquery.com/mailman/listinfo/talk
MK> _______________________________________________
MK> talk at xquery.com
MK> http://xquery.com/mailman/listinfo/talk
--
- Cindy
More information about the talk
mailing list