You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Paul Eggerling-Boeck <pa...@yahoo.com> on 2007/02/23 19:36:36 UTC

jcr:contains question

I'm using  jcr:contains() to query for nodes with a given string in
one of the properties such as the following:

//entry[jcr:contains(@MyProperty,'val')]

That query will not find the following node:
<entry jcr:primaryType="nt:unstructured" MyProperty="My Value"/>

However if I use this query:
//entry[jcr:contains(@MyProperty,'val')]

The node is found.  Seems to me like jcr:contains only matches on
whole words.  Am I wrong?  Is there a way to search on partial words?

BTW, I tried jcr:like with wildcards and that did not work any better,
plus had the additional problem of being case sensitive.

Thanks,

Paul

Re: jcr:contains question

Posted by Paul Eggerling-Boeck <pa...@yahoo.com>.
Thanks all.  I was using the SQL wildcard '%' with the XPATH query.
Works much better with '*'.

On 2/26/07, Marcel Reutegger <ma...@gmx.net> wrote:
> Paul Eggerling-Boeck wrote:
> > BTW, I tried jcr:like with wildcards and that did not work any better,
> > plus had the additional problem of being case sensitive.
>
> as of version 1.2.1 jackrabbit also support the function fn:lower-case in
> combination with jcr:like():
>
> //entry[jcr:like(fn:lower-case(@MyProperty),'my%')]
>
> regards
>  marcel
>

Re: jcr:contains question

Posted by Marcel Reutegger <ma...@gmx.net>.
Paul Eggerling-Boeck wrote:
> BTW, I tried jcr:like with wildcards and that did not work any better,
> plus had the additional problem of being case sensitive.

as of version 1.2.1 jackrabbit also support the function fn:lower-case in 
combination with jcr:like():

//entry[jcr:like(fn:lower-case(@MyProperty),'my%')]

regards
  marcel

Re: jcr:contains question

Posted by Paco Avila <pa...@git.es>.
> I'm using  jcr:contains() to query for nodes with a given string in
> one of the properties such as the following:
>
> //entry[jcr:contains(@MyProperty,'val')]
>
> That query will not find the following node:
> <entry jcr:primaryType="nt:unstructured" MyProperty="My Value"/>
>
> However if I use this query:
> //entry[jcr:contains(@MyProperty,'val')]
>
> The node is found.  Seems to me like jcr:contains only matches on
> whole words.  Am I wrong?  Is there a way to search on partial words?
>
> BTW, I tried jcr:like with wildcards and that did not work any better,
> plus had the additional problem of being case sensitive.

What is the difference between both search? They are equals.

jcr:contains makes a full-text search using Lucene. If you want to search
for the string "val" an get a match with the string "My Value" you should
search "val*".