You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Aarnout van der Meulen <Aa...@e-office.com> on 2006/03/15 13:08:59 UTC

Question about not case-sensitive querying

Hello,

I would like to search for nodes with a given property-value, but not 
case-sensitive.
So, something like  //*[@field1="test"] , but then also resulting nodes 
with property-values "Test', "TEST" and so on.

Can I create such a query? 
Or is there another way to get the desired results?

Aarnout van der Meulen


De informatie in dit e-mailbericht (inclusief aanhangsels) is vertrouwelijk en is alleen bestemd voor de beoogde ontvanger(s). Indien u dit bericht onterecht heeft ontvangen, wordt u verzocht het bericht te retourneren en de ontvangen informatie op geen enkele wijze te gebruiken. 

The information contained in this e-mail (attachments included) may be confidential and is intended solely for the person(s) indicated in the message. Should you have received this e-mail unintentionally, please return it to the sender and do not use the content of the message in any way.

Re: Question about not case-sensitive querying

Posted by Alexandru Popescu <th...@gmail.com>.
Damn this is good news!
Many thanks Marcel.

./alex
--
.w( the_mindstorm )p.

ps: Marcel, I promise the first time we meet I will handle you some good
couple of beers for your help and for the excellent pointers to the spec.

On 3/16/06, Marcel Reutegger <ma...@gmx.net> wrote:
>
> Alexandru Popescu wrote:
> > Is this gonna work with multi-value properties? This is my problem.
> Because
> > doing [@my:property = 1] would mean to me: does the property have the
> value
> > 1, and not does the property contain the value 1 (as would be the case
> for
> > mult-value properties).
>
> this depends which one of the comparison operators you are using ;)
>
> XPath defines 'value comparison' (operators like: eq, gt, lt, ne) and
> 'general comparison' (operators like: =, >, >, !=). The difference
> basically is, that value comparison only returns true for a comparison
> if the property is single valued and general comparison works for both
> single and multi valued properties. In case of a multi valued property a
> general comparison will return true if at least one of the values
> returns true for that comparison.
>
> e.g. if you have my:property = [1,2,3]
>
> @my:property eq 1 -> false
> @my:property = 1 -> true
> @my:property != 2 -> true
>
> See also JCR spec section 6.6.4.10
>
> regards
>   marcel
>
>

Re: Question about not case-sensitive querying

Posted by Marcel Reutegger <ma...@gmx.net>.
Alexandru Popescu wrote:
> Is this gonna work with multi-value properties? This is my problem. Because
> doing [@my:property = 1] would mean to me: does the property have the value
> 1, and not does the property contain the value 1 (as would be the case for
> mult-value properties).

this depends which one of the comparison operators you are using ;)

XPath defines 'value comparison' (operators like: eq, gt, lt, ne) and 
'general comparison' (operators like: =, >, >, !=). The difference 
basically is, that value comparison only returns true for a comparison 
if the property is single valued and general comparison works for both 
single and multi valued properties. In case of a multi valued property a 
general comparison will return true if at least one of the values 
returns true for that comparison.

e.g. if you have my:property = [1,2,3]

@my:property eq 1 -> false
@my:property = 1 -> true
@my:property != 2 -> true

See also JCR spec section 6.6.4.10

regards
  marcel


Re: Question about not case-sensitive querying

Posted by Alexandru Popescu <th...@gmail.com>.
Is this gonna work with multi-value properties? This is my problem. Because
doing [@my:property = 1] would mean to me: does the property have the value
1, and not does the property contain the value 1 (as would be the case for
mult-value properties).

./alex
--
.w( the_mindstorm )p.


On 3/16/06, Marcel Reutegger <ma...@gmx.net> wrote:
>
> Alexandru Popescu wrote:
> > Does the jcr:contains works against multi-value properties too? I have a
> > multi-value property that contains long values, and I wonder if I can
> > something like:
> >
> > //*[jcr:contains(@my:property, '1')]
>
> long values are not fulltext indexed. You have to use the comparison
> operators:
>
> //*[@my:property = 1]
>
> or
>
> //*[@my:property eq 1]
>
>
>
> regards
>   marcel
>

Re: Question about not case-sensitive querying

Posted by Marcel Reutegger <ma...@gmx.net>.
Alexandru Popescu wrote:
> Does the jcr:contains works against multi-value properties too? I have a
> multi-value property that contains long values, and I wonder if I can
> something like:
> 
> //*[jcr:contains(@my:property, '1')]

long values are not fulltext indexed. You have to use the comparison 
operators:

//*[@my:property = 1]

or

//*[@my:property eq 1]



regards
  marcel

Re: Question about not case-sensitive querying

Posted by Alexandru Popescu <th...@gmail.com>.
Does the jcr:contains works against multi-value properties too? I have a
multi-value property that contains long values, and I wonder if I can
something like:

//*[jcr:contains(@my:property, '1')]

tia,

./alex
--
.w( the_mindstorm )p.


On 3/15/06, Marcel Reutegger <ma...@gmx.net> wrote:
>
> Aarnout van der Meulen wrote:
> > I would like to search for nodes with a given property-value, but not
> > case-sensitive.
> > So, something like  //*[@field1="test"] , but then also resulting nodes
> > with property-values "Test', "TEST" and so on.
> >
> > Can I create such a query?
> > Or is there another way to get the desired results?
>
> try the following:
>
> //*[jcr:contains(@field1, 'test')]
>
> or
>
> //*[jcr:contains(., 'test')]
>
> if you want to do a fulltext search on any property of a node.
>
> regards
>   marcel
>
>

Re: Question about not case-sensitive querying

Posted by Marcel Reutegger <ma...@gmx.net>.
Aarnout van der Meulen wrote:
> I would like to search for nodes with a given property-value, but not 
> case-sensitive.
> So, something like  //*[@field1="test"] , but then also resulting nodes 
> with property-values "Test', "TEST" and so on.
> 
> Can I create such a query? 
> Or is there another way to get the desired results?

try the following:

//*[jcr:contains(@field1, 'test')]

or

//*[jcr:contains(., 'test')]

if you want to do a fulltext search on any property of a node.

regards
  marcel