You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by "Prakash Reddy K. L. V." <Pr...@Sun.COM> on 2008/01/14 15:01:11 UTC

Querying for nodes whose name contains "somepattern"

Hi,

I am using jackrabbit as my content repository.
Is there a way to search for nodes whose name contains a particular word 
using XPath?
For example I want to search for all the nodes whose name contains 
"article".

I tried this query : /jcr:root/*article*
This does not work.

I also tried storing the name as property of the node and tried this query :
/jcr:root/*[@propertyName=''article"]
This does not even get those nodes for which the value of the property 
is "article".

Is there any other way to achieve this ?

Thanks,
Prakash




Re: Querying for nodes whose name contains "somepattern"

Posted by Karthik Sudarshan <Ka...@Sun.COM>.
Prakash,
    The @type was meant to be @propertyName, so please replace your 
property name there.

Regards,
Karthik


Karthik Sudarshan wrote:
> Prakash,
>    Did you try the contains method call? Something like :
>
> /jcr:root/nodename[contains(@type,'article')]
>
> The contains works for XML, and I don't know if this works here, but 
> worth trying :)
>
> -Karthik
>
>
> Prakash Reddy K. L. V. wrote:
>>
>> Hi,
>>
>> I am using jackrabbit as my content repository.
>> Is there a way to search for nodes whose name contains a particular 
>> word using XPath?
>> For example I want to search for all the nodes whose name contains 
>> "article".
>>
>> I tried this query : /jcr:root/*article*
>> This does not work.
>>
>> I also tried storing the name as property of the node and tried this 
>> query :
>> /jcr:root/*[@propertyName=''article"]
>> This does not even get those nodes for which the value of the 
>> property is "article".
>>
>> Is there any other way to achieve this ?
>>
>> Thanks,
>> Prakash
>>
>>
>>
>


Re: Querying for nodes whose name contains "somepattern"

Posted by Karthik Sudarshan <Ka...@Sun.COM>.
Prakash,
    Did you try the contains method call? Something like :

/jcr:root/nodename[contains(@type,'article')]

The contains works for XML, and I don't know if this works here, but worth trying :)

-Karthik


Prakash Reddy K. L. V. wrote:
>
> Hi,
>
> I am using jackrabbit as my content repository.
> Is there a way to search for nodes whose name contains a particular 
> word using XPath?
> For example I want to search for all the nodes whose name contains 
> "article".
>
> I tried this query : /jcr:root/*article*
> This does not work.
>
> I also tried storing the name as property of the node and tried this 
> query :
> /jcr:root/*[@propertyName=''article"]
> This does not even get those nodes for which the value of the property 
> is "article".
>
> Is there any other way to achieve this ?
>
> Thanks,
> Prakash
>
>
>


Re: Querying for nodes whose name contains "somepattern"

Posted by "Prakash Reddy K. L. V." <Pr...@Sun.COM>.

I did go through the link. Thanks again for your valuable suggestion.

Regards,
Prakash

Ard Schrijvers wrote:
> Hello,
>
>   
>> Thanks Ard, I can use jcr:contains.
>> But how does it perform better than  jcr:like with respect to 
>> performance ?
>>     
>
> see thread
> http://www.mail-archive.com/dev@jackrabbit.apache.org/msg06993.html 
>
> "jcr:like with a '%' prefix" will not perform is a short recapitulation
> if you are not willing to read all the mails
>
> -Ard
>
>   
>> Regards,
>> Prakash
>>
>> Ard Schrijvers wrote:
>>     
>>> Hello,
>>>
>>>   
>>>       
>>>> Prakash Reddy wrote:
>>>>     
>>>>         
>>>   
>>>       
>>>> I can't do without jcr:like because I need to get all the 
>>>>         
>> nodes whose 
>>     
>>>> property's value contains a given word.
>>>> What are my other alternatives?
>>>>     
>>>>         
>>> A given word in the text of a property....you should really use 
>>> jcr:contains in that case. Can't you use jcr:contains?
>>>
>>> -Ard
>>>
>>>   
>>>       
>>>> Thanks in advance.
>>>>
>>>> Regards,
>>>> Prakash
>>>>
>>>> Ard Schrijvers wrote:
>>>>     
>>>>         
>>>>> Hello,
>>>>>
>>>>> It may work for you at the moment, but a query like 
>>>>> '//*[jcr:like(fn:lower-case(@propertyName), '%article%')]' is
>>>>> *extremely* inefficient. using the jcr:like in combination with a 
>>>>> prefix '%' will most certainly lead to very slow results when the 
>>>>> number of hits grows (even for quite small repositories). If you 
>>>>> really need it, and the number of nodes will grow, you
>>>>>       
>>>>>           
>>>> should really
>>>>     
>>>>         
>>>>> look for a different solution IMO (like using a nodetype 
>>>>>           
>> which you 
>>     
>>>>> search for)
>>>>>
>>>>> Regards Ard
>>>>>
>>>>>   
>>>>>       
>>>>>           
>>>>>> Alessandro,
>>>>>>
>>>>>> Thanks for explaining. Now I understood my mistake.
>>>>>> The mistake I did was I had uppercase letters in the pattern. 
>>>>>> Thats why I was not getting the expected results.
>>>>>> After I changed everything to lower case in the pattern,
>>>>>>         
>>>>>>             
>>>> everything
>>>>     
>>>>         
>>>>>> works fine.
>>>>>>
>>>>>> Thank you and others once again for helping me out.
>>>>>>
>>>>>> Regards,
>>>>>> Prakash
>>>>>>
>>>>>>
>>>>>> Alessandro Bologna wrote:
>>>>>>     
>>>>>>         
>>>>>>             
>>>>>>> Prakash,
>>>>>>>
>>>>>>> maybe I am still not understanding, but 
>>>>>>> //*[jcr:like(fn:lower-case(@propertyName), '%article%')] should 
>>>>>>> actually do what you want. The property values are
>>>>>>>       
>>>>>>>           
>>>>>>>               
>>>>>> converted to lower
>>>>>>     
>>>>>>         
>>>>>>             
>>>>>>> case ("MyArtcilexxx", "MyARTicleyyy" => "myartcilexxx",
>>>>>>> "myarticleyyy") by the lower-case function, and they are
>>>>>>>       
>>>>>>>           
>>>>>>>               
>>>>>> compared to
>>>>>>     
>>>>>>         
>>>>>>             
>>>>>>> the pattern that happens to have lower case characters
>>>>>>>       
>>>>>>>           
>>>>>>>               
>>>>>> there only (so
>>>>>>     
>>>>>>         
>>>>>>             
>>>>>>> you should use lowercase letters on the pattern, of course).
>>>>>>>
>>>>>>> Did you try it?
>>>>>>>
>>>>>>> Alessandro
>>>>>>>
>>>>>>>
>>>>>>> Prakash Reddy K. L. V. wrote:
>>>>>>>       
>>>>>>>           
>>>>>>>               
>>>>>>>> Alessandro,
>>>>>>>>
>>>>>>>> This does not help. fn:lower-case will just convert the
>>>>>>>>             
>>>>>>>>                 
>>>> letters to
>>>>     
>>>>         
>>>>>>>> lower case.
>>>>>>>> May be I was not clear in my earlier mail.
>>>>>>>> I want to retrieve all nodes whose property has values like 
>>>>>>>> "MyArtcilexxx", "MyARTicleyyy", "artcilezzzz" and so on.
>>>>>>>> I want something like String.equalsIgnoreCase("article") .
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>> Prakash
>>>>>>>>
>>>>>>>> Alessandro Bologna wrote:
>>>>>>>>         
>>>>>>>>             
>>>>>>>>                 
>>>>>>>>> Yes,
>>>>>>>>> Try using //*[jcr:like(fn:lower-case(@propertyName),
>>>>>>>>>           
>>>>>>>>>               
>>>>>>>>>                   
>>>>>> '%article%')]
>>>>>>     
>>>>>>         
>>>>>>             
>>>>>>>>> Alessandro
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Prakash Reddy K. L. V. wrote:
>>>>>>>>>           
>>>>>>>>>               
>>>>>>>>>                   
>>>>>>>>>> Hi Alessandro,
>>>>>>>>>>
>>>>>>>>>> Thanks for your response.
>>>>>>>>>> The query //*[jcr:like(@propertyName, '%article%')]
>>>>>>>>>>             
>>>>>>>>>>                 
>>>>>>>>>>                     
>>>>>> seems to work
>>>>>>     
>>>>>>         
>>>>>>             
>>>>>>>>>> for me. But I have a problem here. It seems to be case
>>>>>>>>>>                 
>>>>>>>>>>                     
>>>> sensitive.
>>>>     
>>>>         
>>>>>>>>>> Is there a way to tell jackrabbit to ignore case??
>>>>>>>>>>
>>>>>>>>>> Regards,
>>>>>>>>>> Prakash
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Alessandro Bologna wrote:
>>>>>>>>>>             
>>>>>>>>>>                 
>>>>>>>>>>                     
>>>>>>>>>>> Hi,
>>>>>>>>>>>
>>>>>>>>>>> you can't search for substrings of the node name, but
>>>>>>>>>>>                   
>>>>>>>>>>>                       
>>>> if you do
>>>>     
>>>>         
>>>>>>>>>>> store the node name in a property, then you can use either 
>>>>>>>>>>> jcr:like or jcs:contains (not just "contains", the XPATH in 
>>>>>>>>>>> Jackrabbit doesn't support it).
>>>>>>>>>>>
>>>>>>>>>>> So try:
>>>>>>>>>>>     //*[jcr:contains(@propertyName,'article')]
>>>>>>>>>>>    or:
>>>>>>>>>>>     //*[jcr:like(@propertyName, '%article%')]
>>>>>>>>>>>
>>>>>>>>>>> Further reading here
>>>>>>>>>>>
>>>>>>>>>>>                   
>>>>>>>>>>>                       
>>>> http://www.theserverside.com/tt/articles/article.tss?l=JCRPract
>>>>     
>>>>         
>>>>>>>>>>> and of course the JSR-170 specs.
>>>>>>>>>>>
>>>>>>>>>>> Hope it helps.
>>>>>>>>>>> Alessandro
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Prakash Reddy K. L. V. wrote:
>>>>>>>>>>>               
>>>>>>>>>>>                   
>>>>>>>>>>>                       
>>>>>>>>>>>> Hi,
>>>>>>>>>>>>
>>>>>>>>>>>> I am using jackrabbit as my content repository.
>>>>>>>>>>>> Is there a way to search for nodes whose name contains a 
>>>>>>>>>>>> particular word using XPath?
>>>>>>>>>>>> For example I want to search for all the nodes whose name 
>>>>>>>>>>>> contains "article".
>>>>>>>>>>>>
>>>>>>>>>>>> I tried this query : /jcr:root/*article* This does 
>>>>>>>>>>>>                         
>> not work.
>>     
>>>>>>>>>>>> I also tried storing the name as property of the node
>>>>>>>>>>>>                 
>>>>>>>>>>>>                     
>>>>>>>>>>>>                         
>>>>>> and tried
>>>>>>     
>>>>>>         
>>>>>>             
>>>>>>>>>>>> this query :
>>>>>>>>>>>> /jcr:root/*[@propertyName=''article"]
>>>>>>>>>>>> This does not even get those nodes for which the
>>>>>>>>>>>>                     
>>>>>>>>>>>>                         
>>>> value of the
>>>>     
>>>>         
>>>>>>>>>>>> property is "article".
>>>>>>>>>>>>
>>>>>>>>>>>> Is there any other way to achieve this ?
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks,
>>>>>>>>>>>> Prakash
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                 
>>>>>>>>>>>>                     
>>>>>>>>>>>>                         
>>>>>>     
>>>>>>         
>>>>>>             
>>>>     
>>>>         
>>     


RE: Querying for nodes whose name contains "somepattern"

Posted by Ard Schrijvers <a....@hippo.nl>.
Hello,

> 
> Thanks Ard, I can use jcr:contains.
> But how does it perform better than  jcr:like with respect to 
> performance ?

see thread
http://www.mail-archive.com/dev@jackrabbit.apache.org/msg06993.html 

"jcr:like with a '%' prefix" will not perform is a short recapitulation
if you are not willing to read all the mails

-Ard

> 
> Regards,
> Prakash
> 
> Ard Schrijvers wrote:
> > Hello,
> >
> >   
> >> Prakash Reddy wrote:
> >>     
> >
> >   
> >> I can't do without jcr:like because I need to get all the 
> nodes whose 
> >> property's value contains a given word.
> >> What are my other alternatives?
> >>     
> >
> > A given word in the text of a property....you should really use 
> > jcr:contains in that case. Can't you use jcr:contains?
> >
> > -Ard
> >
> >   
> >> Thanks in advance.
> >>
> >> Regards,
> >> Prakash
> >>
> >> Ard Schrijvers wrote:
> >>     
> >>> Hello,
> >>>
> >>> It may work for you at the moment, but a query like 
> >>> '//*[jcr:like(fn:lower-case(@propertyName), '%article%')]' is
> >>> *extremely* inefficient. using the jcr:like in combination with a 
> >>> prefix '%' will most certainly lead to very slow results when the 
> >>> number of hits grows (even for quite small repositories). If you 
> >>> really need it, and the number of nodes will grow, you
> >>>       
> >> should really
> >>     
> >>> look for a different solution IMO (like using a nodetype 
> which you 
> >>> search for)
> >>>
> >>> Regards Ard
> >>>
> >>>   
> >>>       
> >>>> Alessandro,
> >>>>
> >>>> Thanks for explaining. Now I understood my mistake.
> >>>> The mistake I did was I had uppercase letters in the pattern. 
> >>>> Thats why I was not getting the expected results.
> >>>> After I changed everything to lower case in the pattern,
> >>>>         
> >> everything
> >>     
> >>>> works fine.
> >>>>
> >>>> Thank you and others once again for helping me out.
> >>>>
> >>>> Regards,
> >>>> Prakash
> >>>>
> >>>>
> >>>> Alessandro Bologna wrote:
> >>>>     
> >>>>         
> >>>>> Prakash,
> >>>>>
> >>>>> maybe I am still not understanding, but 
> >>>>> //*[jcr:like(fn:lower-case(@propertyName), '%article%')] should 
> >>>>> actually do what you want. The property values are
> >>>>>       
> >>>>>           
> >>>> converted to lower
> >>>>     
> >>>>         
> >>>>> case ("MyArtcilexxx", "MyARTicleyyy" => "myartcilexxx",
> >>>>> "myarticleyyy") by the lower-case function, and they are
> >>>>>       
> >>>>>           
> >>>> compared to
> >>>>     
> >>>>         
> >>>>> the pattern that happens to have lower case characters
> >>>>>       
> >>>>>           
> >>>> there only (so
> >>>>     
> >>>>         
> >>>>> you should use lowercase letters on the pattern, of course).
> >>>>>
> >>>>> Did you try it?
> >>>>>
> >>>>> Alessandro
> >>>>>
> >>>>>
> >>>>> Prakash Reddy K. L. V. wrote:
> >>>>>       
> >>>>>           
> >>>>>> Alessandro,
> >>>>>>
> >>>>>> This does not help. fn:lower-case will just convert the
> >>>>>>             
> >> letters to
> >>     
> >>>>>> lower case.
> >>>>>> May be I was not clear in my earlier mail.
> >>>>>> I want to retrieve all nodes whose property has values like 
> >>>>>> "MyArtcilexxx", "MyARTicleyyy", "artcilezzzz" and so on.
> >>>>>> I want something like String.equalsIgnoreCase("article") .
> >>>>>>
> >>>>>> Regards,
> >>>>>> Prakash
> >>>>>>
> >>>>>> Alessandro Bologna wrote:
> >>>>>>         
> >>>>>>             
> >>>>>>> Yes,
> >>>>>>> Try using //*[jcr:like(fn:lower-case(@propertyName),
> >>>>>>>           
> >>>>>>>               
> >>>> '%article%')]
> >>>>     
> >>>>         
> >>>>>>> Alessandro
> >>>>>>>
> >>>>>>>
> >>>>>>> Prakash Reddy K. L. V. wrote:
> >>>>>>>           
> >>>>>>>               
> >>>>>>>> Hi Alessandro,
> >>>>>>>>
> >>>>>>>> Thanks for your response.
> >>>>>>>> The query //*[jcr:like(@propertyName, '%article%')]
> >>>>>>>>             
> >>>>>>>>                 
> >>>> seems to work
> >>>>     
> >>>>         
> >>>>>>>> for me. But I have a problem here. It seems to be case
> >>>>>>>>                 
> >> sensitive.
> >>     
> >>>>>>>> Is there a way to tell jackrabbit to ignore case??
> >>>>>>>>
> >>>>>>>> Regards,
> >>>>>>>> Prakash
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> Alessandro Bologna wrote:
> >>>>>>>>             
> >>>>>>>>                 
> >>>>>>>>> Hi,
> >>>>>>>>>
> >>>>>>>>> you can't search for substrings of the node name, but
> >>>>>>>>>                   
> >> if you do
> >>     
> >>>>>>>>> store the node name in a property, then you can use either 
> >>>>>>>>> jcr:like or jcs:contains (not just "contains", the XPATH in 
> >>>>>>>>> Jackrabbit doesn't support it).
> >>>>>>>>>
> >>>>>>>>> So try:
> >>>>>>>>>     //*[jcr:contains(@propertyName,'article')]
> >>>>>>>>>    or:
> >>>>>>>>>     //*[jcr:like(@propertyName, '%article%')]
> >>>>>>>>>
> >>>>>>>>> Further reading here
> >>>>>>>>>
> >>>>>>>>>                   
> >> http://www.theserverside.com/tt/articles/article.tss?l=JCRPract
> >>     
> >>>>>>>>> and of course the JSR-170 specs.
> >>>>>>>>>
> >>>>>>>>> Hope it helps.
> >>>>>>>>> Alessandro
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> Prakash Reddy K. L. V. wrote:
> >>>>>>>>>               
> >>>>>>>>>                   
> >>>>>>>>>> Hi,
> >>>>>>>>>>
> >>>>>>>>>> I am using jackrabbit as my content repository.
> >>>>>>>>>> Is there a way to search for nodes whose name contains a 
> >>>>>>>>>> particular word using XPath?
> >>>>>>>>>> For example I want to search for all the nodes whose name 
> >>>>>>>>>> contains "article".
> >>>>>>>>>>
> >>>>>>>>>> I tried this query : /jcr:root/*article* This does 
> not work.
> >>>>>>>>>>
> >>>>>>>>>> I also tried storing the name as property of the node
> >>>>>>>>>>                 
> >>>>>>>>>>                     
> >>>> and tried
> >>>>     
> >>>>         
> >>>>>>>>>> this query :
> >>>>>>>>>> /jcr:root/*[@propertyName=''article"]
> >>>>>>>>>> This does not even get those nodes for which the
> >>>>>>>>>>                     
> >> value of the
> >>     
> >>>>>>>>>> property is "article".
> >>>>>>>>>>
> >>>>>>>>>> Is there any other way to achieve this ?
> >>>>>>>>>>
> >>>>>>>>>> Thanks,
> >>>>>>>>>> Prakash
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>                 
> >>>>>>>>>>                     
> >>>>     
> >>>>         
> >>
> >>     
> 
> 

Re: Querying for nodes whose name contains "somepattern"

Posted by "Prakash Reddy K. L. V." <Pr...@Sun.COM>.

Thanks Ard, I can use jcr:contains.
But how does it perform better than  jcr:like with respect to performance ?

Regards,
Prakash

Ard Schrijvers wrote:
> Hello,
>
>   
>> Prakash Reddy wrote:
>>     
>
>   
>> I can't do without jcr:like because I need to get all the 
>> nodes whose property's value contains a given word.
>> What are my other alternatives?
>>     
>
> A given word in the text of a property....you should really use
> jcr:contains in that case. Can't you use jcr:contains?
>
> -Ard
>
>   
>> Thanks in advance.
>>
>> Regards,
>> Prakash
>>
>> Ard Schrijvers wrote:
>>     
>>> Hello,
>>>
>>> It may work for you at the moment, but a query like 
>>> '//*[jcr:like(fn:lower-case(@propertyName), '%article%')]' is
>>> *extremely* inefficient. using the jcr:like in combination with a 
>>> prefix '%' will most certainly lead to very slow results when the 
>>> number of hits grows (even for quite small repositories). If you 
>>> really need it, and the number of nodes will grow, you 
>>>       
>> should really 
>>     
>>> look for a different solution IMO (like using a nodetype which you 
>>> search for)
>>>
>>> Regards Ard
>>>
>>>   
>>>       
>>>> Alessandro,
>>>>
>>>> Thanks for explaining. Now I understood my mistake.
>>>> The mistake I did was I had uppercase letters in the pattern. 
>>>> Thats why I was not getting the expected results.
>>>> After I changed everything to lower case in the pattern, 
>>>>         
>> everything 
>>     
>>>> works fine.
>>>>
>>>> Thank you and others once again for helping me out.
>>>>
>>>> Regards,
>>>> Prakash
>>>>
>>>>
>>>> Alessandro Bologna wrote:
>>>>     
>>>>         
>>>>> Prakash,
>>>>>
>>>>> maybe I am still not understanding, but 
>>>>> //*[jcr:like(fn:lower-case(@propertyName), '%article%')] should 
>>>>> actually do what you want. The property values are
>>>>>       
>>>>>           
>>>> converted to lower
>>>>     
>>>>         
>>>>> case ("MyArtcilexxx", "MyARTicleyyy" => "myartcilexxx",
>>>>> "myarticleyyy") by the lower-case function, and they are
>>>>>       
>>>>>           
>>>> compared to
>>>>     
>>>>         
>>>>> the pattern that happens to have lower case characters
>>>>>       
>>>>>           
>>>> there only (so
>>>>     
>>>>         
>>>>> you should use lowercase letters on the pattern, of course).
>>>>>
>>>>> Did you try it?
>>>>>
>>>>> Alessandro
>>>>>
>>>>>
>>>>> Prakash Reddy K. L. V. wrote:
>>>>>       
>>>>>           
>>>>>> Alessandro,
>>>>>>
>>>>>> This does not help. fn:lower-case will just convert the 
>>>>>>             
>> letters to 
>>     
>>>>>> lower case.
>>>>>> May be I was not clear in my earlier mail.
>>>>>> I want to retrieve all nodes whose property has values like 
>>>>>> "MyArtcilexxx", "MyARTicleyyy", "artcilezzzz" and so on.
>>>>>> I want something like String.equalsIgnoreCase("article") .
>>>>>>
>>>>>> Regards,
>>>>>> Prakash
>>>>>>
>>>>>> Alessandro Bologna wrote:
>>>>>>         
>>>>>>             
>>>>>>> Yes,
>>>>>>> Try using //*[jcr:like(fn:lower-case(@propertyName),
>>>>>>>           
>>>>>>>               
>>>> '%article%')]
>>>>     
>>>>         
>>>>>>> Alessandro
>>>>>>>
>>>>>>>
>>>>>>> Prakash Reddy K. L. V. wrote:
>>>>>>>           
>>>>>>>               
>>>>>>>> Hi Alessandro,
>>>>>>>>
>>>>>>>> Thanks for your response.
>>>>>>>> The query //*[jcr:like(@propertyName, '%article%')]
>>>>>>>>             
>>>>>>>>                 
>>>> seems to work
>>>>     
>>>>         
>>>>>>>> for me. But I have a problem here. It seems to be case 
>>>>>>>>                 
>> sensitive.
>>     
>>>>>>>> Is there a way to tell jackrabbit to ignore case??
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>> Prakash
>>>>>>>>
>>>>>>>>
>>>>>>>> Alessandro Bologna wrote:
>>>>>>>>             
>>>>>>>>                 
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> you can't search for substrings of the node name, but 
>>>>>>>>>                   
>> if you do 
>>     
>>>>>>>>> store the node name in a property, then you can use either 
>>>>>>>>> jcr:like or jcs:contains (not just "contains", the XPATH in 
>>>>>>>>> Jackrabbit doesn't support it).
>>>>>>>>>
>>>>>>>>> So try:
>>>>>>>>>     //*[jcr:contains(@propertyName,'article')]
>>>>>>>>>    or:
>>>>>>>>>     //*[jcr:like(@propertyName, '%article%')]
>>>>>>>>>
>>>>>>>>> Further reading here
>>>>>>>>>
>>>>>>>>>                   
>> http://www.theserverside.com/tt/articles/article.tss?l=JCRPract
>>     
>>>>>>>>> and of course the JSR-170 specs.
>>>>>>>>>
>>>>>>>>> Hope it helps.
>>>>>>>>> Alessandro
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Prakash Reddy K. L. V. wrote:
>>>>>>>>>               
>>>>>>>>>                   
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> I am using jackrabbit as my content repository.
>>>>>>>>>> Is there a way to search for nodes whose name contains a 
>>>>>>>>>> particular word using XPath?
>>>>>>>>>> For example I want to search for all the nodes whose name 
>>>>>>>>>> contains "article".
>>>>>>>>>>
>>>>>>>>>> I tried this query : /jcr:root/*article* This does not work.
>>>>>>>>>>
>>>>>>>>>> I also tried storing the name as property of the node
>>>>>>>>>>                 
>>>>>>>>>>                     
>>>> and tried
>>>>     
>>>>         
>>>>>>>>>> this query :
>>>>>>>>>> /jcr:root/*[@propertyName=''article"]
>>>>>>>>>> This does not even get those nodes for which the 
>>>>>>>>>>                     
>> value of the 
>>     
>>>>>>>>>> property is "article".
>>>>>>>>>>
>>>>>>>>>> Is there any other way to achieve this ?
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>> Prakash
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                 
>>>>>>>>>>                     
>>>>     
>>>>         
>>
>>     


RE: Querying for nodes whose name contains "somepattern"

Posted by Ard Schrijvers <a....@hippo.nl>.
Hello,

> Prakash Reddy wrote:

> I can't do without jcr:like because I need to get all the 
> nodes whose property's value contains a given word.
> What are my other alternatives?

A given word in the text of a property....you should really use
jcr:contains in that case. Can't you use jcr:contains?

-Ard

> 
> Thanks in advance.
> 
> Regards,
> Prakash
> 
> Ard Schrijvers wrote:
> > Hello,
> >
> > It may work for you at the moment, but a query like 
> > '//*[jcr:like(fn:lower-case(@propertyName), '%article%')]' is
> > *extremely* inefficient. using the jcr:like in combination with a 
> > prefix '%' will most certainly lead to very slow results when the 
> > number of hits grows (even for quite small repositories). If you 
> > really need it, and the number of nodes will grow, you 
> should really 
> > look for a different solution IMO (like using a nodetype which you 
> > search for)
> >
> > Regards Ard
> >
> >   
> >> Alessandro,
> >>
> >> Thanks for explaining. Now I understood my mistake.
> >> The mistake I did was I had uppercase letters in the pattern. 
> >> Thats why I was not getting the expected results.
> >> After I changed everything to lower case in the pattern, 
> everything 
> >> works fine.
> >>
> >> Thank you and others once again for helping me out.
> >>
> >> Regards,
> >> Prakash
> >>
> >>
> >> Alessandro Bologna wrote:
> >>     
> >>> Prakash,
> >>>
> >>> maybe I am still not understanding, but 
> >>> //*[jcr:like(fn:lower-case(@propertyName), '%article%')] should 
> >>> actually do what you want. The property values are
> >>>       
> >> converted to lower
> >>     
> >>> case ("MyArtcilexxx", "MyARTicleyyy" => "myartcilexxx",
> >>> "myarticleyyy") by the lower-case function, and they are
> >>>       
> >> compared to
> >>     
> >>> the pattern that happens to have lower case characters
> >>>       
> >> there only (so
> >>     
> >>> you should use lowercase letters on the pattern, of course).
> >>>
> >>> Did you try it?
> >>>
> >>> Alessandro
> >>>
> >>>
> >>> Prakash Reddy K. L. V. wrote:
> >>>       
> >>>> Alessandro,
> >>>>
> >>>> This does not help. fn:lower-case will just convert the 
> letters to 
> >>>> lower case.
> >>>> May be I was not clear in my earlier mail.
> >>>> I want to retrieve all nodes whose property has values like 
> >>>> "MyArtcilexxx", "MyARTicleyyy", "artcilezzzz" and so on.
> >>>> I want something like String.equalsIgnoreCase("article") .
> >>>>
> >>>> Regards,
> >>>> Prakash
> >>>>
> >>>> Alessandro Bologna wrote:
> >>>>         
> >>>>> Yes,
> >>>>> Try using //*[jcr:like(fn:lower-case(@propertyName),
> >>>>>           
> >> '%article%')]
> >>     
> >>>>> Alessandro
> >>>>>
> >>>>>
> >>>>> Prakash Reddy K. L. V. wrote:
> >>>>>           
> >>>>>> Hi Alessandro,
> >>>>>>
> >>>>>> Thanks for your response.
> >>>>>> The query //*[jcr:like(@propertyName, '%article%')]
> >>>>>>             
> >> seems to work
> >>     
> >>>>>> for me. But I have a problem here. It seems to be case 
> sensitive.
> >>>>>> Is there a way to tell jackrabbit to ignore case??
> >>>>>>
> >>>>>> Regards,
> >>>>>> Prakash
> >>>>>>
> >>>>>>
> >>>>>> Alessandro Bologna wrote:
> >>>>>>             
> >>>>>>> Hi,
> >>>>>>>
> >>>>>>> you can't search for substrings of the node name, but 
> if you do 
> >>>>>>> store the node name in a property, then you can use either 
> >>>>>>> jcr:like or jcs:contains (not just "contains", the XPATH in 
> >>>>>>> Jackrabbit doesn't support it).
> >>>>>>>
> >>>>>>> So try:
> >>>>>>>     //*[jcr:contains(@propertyName,'article')]
> >>>>>>>    or:
> >>>>>>>     //*[jcr:like(@propertyName, '%article%')]
> >>>>>>>
> >>>>>>> Further reading here
> >>>>>>> 
> http://www.theserverside.com/tt/articles/article.tss?l=JCRPract
> >>>>>>> and of course the JSR-170 specs.
> >>>>>>>
> >>>>>>> Hope it helps.
> >>>>>>> Alessandro
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> Prakash Reddy K. L. V. wrote:
> >>>>>>>               
> >>>>>>>> Hi,
> >>>>>>>>
> >>>>>>>> I am using jackrabbit as my content repository.
> >>>>>>>> Is there a way to search for nodes whose name contains a 
> >>>>>>>> particular word using XPath?
> >>>>>>>> For example I want to search for all the nodes whose name 
> >>>>>>>> contains "article".
> >>>>>>>>
> >>>>>>>> I tried this query : /jcr:root/*article* This does not work.
> >>>>>>>>
> >>>>>>>> I also tried storing the name as property of the node
> >>>>>>>>                 
> >> and tried
> >>     
> >>>>>>>> this query :
> >>>>>>>> /jcr:root/*[@propertyName=''article"]
> >>>>>>>> This does not even get those nodes for which the 
> value of the 
> >>>>>>>> property is "article".
> >>>>>>>>
> >>>>>>>> Is there any other way to achieve this ?
> >>>>>>>>
> >>>>>>>> Thanks,
> >>>>>>>> Prakash
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>                 
> >>     
> 
> 
> 

Re: Querying for nodes whose name contains "somepattern"

Posted by "Prakash Reddy K. L. V." <Pr...@Sun.COM>.
Hi Ard,

I can't do without jcr:like because I need to get all the nodes whose 
property's value contains a given word.
What are my other alternatives?

Thanks in advance.

Regards,
Prakash

Ard Schrijvers wrote:
> Hello,
>
> It may work for you at the moment, but a query like
> '//*[jcr:like(fn:lower-case(@propertyName), '%article%')]' is
> *extremely* inefficient. using the jcr:like in combination with a prefix
> '%' will most certainly lead to very slow results when the number of
> hits grows (even for quite small repositories). If you really need it,
> and the number of nodes will grow, you should really look for a
> different solution IMO (like using a nodetype which you search for)
>
> Regards Ard
>
>   
>> Alessandro,
>>
>> Thanks for explaining. Now I understood my mistake.
>> The mistake I did was I had uppercase letters in the pattern. 
>> Thats why I was not getting the expected results.
>> After I changed everything to lower case in the pattern, 
>> everything works fine.
>>
>> Thank you and others once again for helping me out.
>>
>> Regards,
>> Prakash
>>
>>
>> Alessandro Bologna wrote:
>>     
>>> Prakash,
>>>
>>> maybe I am still not understanding, but 
>>> //*[jcr:like(fn:lower-case(@propertyName), '%article%')] should 
>>> actually do what you want. The property values are 
>>>       
>> converted to lower 
>>     
>>> case ("MyArtcilexxx", "MyARTicleyyy" => "myartcilexxx",
>>> "myarticleyyy") by the lower-case function, and they are 
>>>       
>> compared to 
>>     
>>> the pattern that happens to have lower case characters 
>>>       
>> there only (so 
>>     
>>> you should use lowercase letters on the pattern, of course).
>>>
>>> Did you try it?
>>>
>>> Alessandro
>>>
>>>
>>> Prakash Reddy K. L. V. wrote:
>>>       
>>>> Alessandro,
>>>>
>>>> This does not help. fn:lower-case will just convert the letters to 
>>>> lower case.
>>>> May be I was not clear in my earlier mail.
>>>> I want to retrieve all nodes whose property has values like 
>>>> "MyArtcilexxx", "MyARTicleyyy", "artcilezzzz" and so on.
>>>> I want something like String.equalsIgnoreCase("article") .
>>>>
>>>> Regards,
>>>> Prakash
>>>>
>>>> Alessandro Bologna wrote:
>>>>         
>>>>> Yes,
>>>>> Try using //*[jcr:like(fn:lower-case(@propertyName), 
>>>>>           
>> '%article%')] 
>>     
>>>>> Alessandro
>>>>>
>>>>>
>>>>> Prakash Reddy K. L. V. wrote:
>>>>>           
>>>>>> Hi Alessandro,
>>>>>>
>>>>>> Thanks for your response.
>>>>>> The query //*[jcr:like(@propertyName, '%article%')] 
>>>>>>             
>> seems to work 
>>     
>>>>>> for me. But I have a problem here. It seems to be case sensitive.
>>>>>> Is there a way to tell jackrabbit to ignore case??
>>>>>>
>>>>>> Regards,
>>>>>> Prakash
>>>>>>
>>>>>>
>>>>>> Alessandro Bologna wrote:
>>>>>>             
>>>>>>> Hi,
>>>>>>>
>>>>>>> you can't search for substrings of the node name, but if you do 
>>>>>>> store the node name in a property, then you can use either 
>>>>>>> jcr:like or jcs:contains (not just "contains", the XPATH in 
>>>>>>> Jackrabbit doesn't support it).
>>>>>>>
>>>>>>> So try:
>>>>>>>     //*[jcr:contains(@propertyName,'article')]
>>>>>>>    or:
>>>>>>>     //*[jcr:like(@propertyName, '%article%')]
>>>>>>>
>>>>>>> Further reading here
>>>>>>> http://www.theserverside.com/tt/articles/article.tss?l=JCRPract
>>>>>>> and of course the JSR-170 specs.
>>>>>>>
>>>>>>> Hope it helps.
>>>>>>> Alessandro
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Prakash Reddy K. L. V. wrote:
>>>>>>>               
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I am using jackrabbit as my content repository.
>>>>>>>> Is there a way to search for nodes whose name contains a 
>>>>>>>> particular word using XPath?
>>>>>>>> For example I want to search for all the nodes whose name 
>>>>>>>> contains "article".
>>>>>>>>
>>>>>>>> I tried this query : /jcr:root/*article* This does not work.
>>>>>>>>
>>>>>>>> I also tried storing the name as property of the node 
>>>>>>>>                 
>> and tried 
>>     
>>>>>>>> this query :
>>>>>>>> /jcr:root/*[@propertyName=''article"]
>>>>>>>> This does not even get those nodes for which the value of the 
>>>>>>>> property is "article".
>>>>>>>>
>>>>>>>> Is there any other way to achieve this ?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Prakash
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>     



RE: Querying for nodes whose name contains "somepattern"

Posted by Ard Schrijvers <a....@hippo.nl>.
> Ard Schrijvers wrote:
> > It may work for you at the moment, but a query like 
> > '//*[jcr:like(fn:lower-case(@propertyName), '%article%')]' is
> > *extremely* inefficient. using the jcr:like in combination with a 
> > prefix '%' will most certainly lead to very slow results when the 
> > number of hits grows (even for quite small repositories).

> Marcel Reutegger wrote:
> just a small clarification. jcr:like becomes inefficient when 
> the number of distinct values for the property grows. if you 
> only have a handful of distinct values for that property and 
> assign them to one million nodes the query will still be efficient.

Never realized that but that makes sense. 

A site note for those wondering why it is like this: the behavior is not
a result of the Jackrabbit implementation, but inherently part of Lucene
[1] (guessing here, but I think part of any search engine based on an
inverted index): 'In order to prevent extremely slow WildcardQueries, a
Wildcard term should not start with one of the wildcards * or ?'

[1]
http://lucene.zones.apache.org:8080/hudson/job/Lucene-Nightly/javadoc/or
g/apache/lucene/search/WildcardQuery.html

-Ard

> 
> regards
>   marcel
> 

Re: Querying for nodes whose name contains "somepattern"

Posted by Marcel Reutegger <ma...@gmx.net>.
Ard Schrijvers wrote:
> It may work for you at the moment, but a query like
> '//*[jcr:like(fn:lower-case(@propertyName), '%article%')]' is
> *extremely* inefficient. using the jcr:like in combination with a prefix
> '%' will most certainly lead to very slow results when the number of
> hits grows (even for quite small repositories).

just a small clarification. jcr:like becomes inefficient when the number of 
distinct values for the property grows. if you only have a handful of distinct 
values for that property and assign them to one million nodes the query will 
still be efficient.

regards
  marcel

RE: Querying for nodes whose name contains "somepattern"

Posted by Ard Schrijvers <a....@hippo.nl>.
Hello,

It may work for you at the moment, but a query like
'//*[jcr:like(fn:lower-case(@propertyName), '%article%')]' is
*extremely* inefficient. using the jcr:like in combination with a prefix
'%' will most certainly lead to very slow results when the number of
hits grows (even for quite small repositories). If you really need it,
and the number of nodes will grow, you should really look for a
different solution IMO (like using a nodetype which you search for)

Regards Ard

> 
> Alessandro,
> 
> Thanks for explaining. Now I understood my mistake.
> The mistake I did was I had uppercase letters in the pattern. 
> Thats why I was not getting the expected results.
> After I changed everything to lower case in the pattern, 
> everything works fine.
> 
> Thank you and others once again for helping me out.
> 
> Regards,
> Prakash
> 
> 
> Alessandro Bologna wrote:
> > Prakash,
> >
> > maybe I am still not understanding, but 
> > //*[jcr:like(fn:lower-case(@propertyName), '%article%')] should 
> > actually do what you want. The property values are 
> converted to lower 
> > case ("MyArtcilexxx", "MyARTicleyyy" => "myartcilexxx",
> > "myarticleyyy") by the lower-case function, and they are 
> compared to 
> > the pattern that happens to have lower case characters 
> there only (so 
> > you should use lowercase letters on the pattern, of course).
> >
> > Did you try it?
> >
> > Alessandro
> >
> >
> > Prakash Reddy K. L. V. wrote:
> >>
> >> Alessandro,
> >>
> >> This does not help. fn:lower-case will just convert the letters to 
> >> lower case.
> >> May be I was not clear in my earlier mail.
> >> I want to retrieve all nodes whose property has values like 
> >> "MyArtcilexxx", "MyARTicleyyy", "artcilezzzz" and so on.
> >> I want something like String.equalsIgnoreCase("article") .
> >>
> >> Regards,
> >> Prakash
> >>
> >> Alessandro Bologna wrote:
> >>> Yes,
> >>> Try using //*[jcr:like(fn:lower-case(@propertyName), 
> '%article%')] 
> >>> Alessandro
> >>>
> >>>
> >>> Prakash Reddy K. L. V. wrote:
> >>>>
> >>>> Hi Alessandro,
> >>>>
> >>>> Thanks for your response.
> >>>> The query //*[jcr:like(@propertyName, '%article%')] 
> seems to work 
> >>>> for me. But I have a problem here. It seems to be case sensitive.
> >>>> Is there a way to tell jackrabbit to ignore case??
> >>>>
> >>>> Regards,
> >>>> Prakash
> >>>>
> >>>>
> >>>> Alessandro Bologna wrote:
> >>>>> Hi,
> >>>>>
> >>>>> you can't search for substrings of the node name, but if you do 
> >>>>> store the node name in a property, then you can use either 
> >>>>> jcr:like or jcs:contains (not just "contains", the XPATH in 
> >>>>> Jackrabbit doesn't support it).
> >>>>>
> >>>>> So try:
> >>>>>     //*[jcr:contains(@propertyName,'article')]
> >>>>>    or:
> >>>>>     //*[jcr:like(@propertyName, '%article%')]
> >>>>>
> >>>>> Further reading here
> >>>>> http://www.theserverside.com/tt/articles/article.tss?l=JCRPract
> >>>>> and of course the JSR-170 specs.
> >>>>>
> >>>>> Hope it helps.
> >>>>> Alessandro
> >>>>>
> >>>>>
> >>>>>
> >>>>> Prakash Reddy K. L. V. wrote:
> >>>>>>
> >>>>>> Hi,
> >>>>>>
> >>>>>> I am using jackrabbit as my content repository.
> >>>>>> Is there a way to search for nodes whose name contains a 
> >>>>>> particular word using XPath?
> >>>>>> For example I want to search for all the nodes whose name 
> >>>>>> contains "article".
> >>>>>>
> >>>>>> I tried this query : /jcr:root/*article* This does not work.
> >>>>>>
> >>>>>> I also tried storing the name as property of the node 
> and tried 
> >>>>>> this query :
> >>>>>> /jcr:root/*[@propertyName=''article"]
> >>>>>> This does not even get those nodes for which the value of the 
> >>>>>> property is "article".
> >>>>>>
> >>>>>> Is there any other way to achieve this ?
> >>>>>>
> >>>>>> Thanks,
> >>>>>> Prakash
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>
> >>>
> >>
> >
> 
> 

Re: Querying for nodes whose name contains "somepattern"

Posted by Alessandro Bologna <al...@gmail.com>.
No problems,

glad it worked.
Alessandro


Prakash Reddy K. L. V. wrote:
>
>
> Alessandro,
>
> Thanks for explaining. Now I understood my mistake.
> The mistake I did was I had uppercase letters in the pattern. Thats 
> why I was not getting the expected results.
> After I changed everything to lower case in the pattern, everything 
> works fine.
>
> Thank you and others once again for helping me out.
>
> Regards,
> Prakash
>


Re: Querying for nodes whose name contains "somepattern"

Posted by "Prakash Reddy K. L. V." <Pr...@Sun.COM>.

Alessandro,

Thanks for explaining. Now I understood my mistake.
The mistake I did was I had uppercase letters in the pattern. Thats why 
I was not getting the expected results.
After I changed everything to lower case in the pattern, everything 
works fine.

Thank you and others once again for helping me out.

Regards,
Prakash


Alessandro Bologna wrote:
> Prakash,
>
> maybe I am still not understanding, but 
> //*[jcr:like(fn:lower-case(@propertyName), '%article%')] should 
> actually do what you want. The property values are converted to lower 
> case ("MyArtcilexxx", "MyARTicleyyy" => "myartcilexxx", 
> "myarticleyyy") by the lower-case function, and they are compared to 
> the pattern that happens to have lower case characters there only (so 
> you should use lowercase letters on the pattern, of course).
>
> Did you try it?
>
> Alessandro
>
>
> Prakash Reddy K. L. V. wrote:
>>
>> Alessandro,
>>
>> This does not help. fn:lower-case will just convert the letters to 
>> lower case.
>> May be I was not clear in my earlier mail.
>> I want to retrieve all nodes whose property has values like 
>> "MyArtcilexxx", "MyARTicleyyy", "artcilezzzz" and so on.
>> I want something like String.equalsIgnoreCase("article") .
>>
>> Regards,
>> Prakash
>>
>> Alessandro Bologna wrote:
>>> Yes,
>>> Try using //*[jcr:like(fn:lower-case(@propertyName), '%article%')] 
>>> Alessandro
>>>
>>>
>>> Prakash Reddy K. L. V. wrote:
>>>>
>>>> Hi Alessandro,
>>>>
>>>> Thanks for your response.
>>>> The query //*[jcr:like(@propertyName, '%article%')] seems to work 
>>>> for me. But I have a problem here. It seems to be case sensitive.
>>>> Is there a way to tell jackrabbit to ignore case??
>>>>
>>>> Regards,
>>>> Prakash
>>>>
>>>>
>>>> Alessandro Bologna wrote:
>>>>> Hi,
>>>>>
>>>>> you can't search for substrings of the node name, but if you do 
>>>>> store the node name in a property, then you can use either 
>>>>> jcr:like or jcs:contains (not just "contains", the XPATH in 
>>>>> Jackrabbit doesn't support it).
>>>>>
>>>>> So try:
>>>>>     //*[jcr:contains(@propertyName,'article')]
>>>>>    or:
>>>>>     //*[jcr:like(@propertyName, '%article%')]
>>>>>
>>>>> Further reading here 
>>>>> http://www.theserverside.com/tt/articles/article.tss?l=JCRPract  
>>>>> and of course the JSR-170 specs.
>>>>>
>>>>> Hope it helps.
>>>>> Alessandro
>>>>>
>>>>>
>>>>>
>>>>> Prakash Reddy K. L. V. wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I am using jackrabbit as my content repository.
>>>>>> Is there a way to search for nodes whose name contains a 
>>>>>> particular word using XPath?
>>>>>> For example I want to search for all the nodes whose name 
>>>>>> contains "article".
>>>>>>
>>>>>> I tried this query : /jcr:root/*article*
>>>>>> This does not work.
>>>>>>
>>>>>> I also tried storing the name as property of the node and tried 
>>>>>> this query :
>>>>>> /jcr:root/*[@propertyName=''article"]
>>>>>> This does not even get those nodes for which the value of the 
>>>>>> property is "article".
>>>>>>
>>>>>> Is there any other way to achieve this ?
>>>>>>
>>>>>> Thanks,
>>>>>> Prakash
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>


Re: Querying for nodes whose name contains "somepattern"

Posted by Alessandro Bologna <al...@gmail.com>.
Prakash,

maybe I am still not understanding, but 
//*[jcr:like(fn:lower-case(@propertyName), '%article%')] should actually 
do what you want. The property values are converted to lower case 
("MyArtcilexxx", "MyARTicleyyy" => "myartcilexxx", "myarticleyyy") by 
the lower-case function, and they are compared to the pattern that 
happens to have lower case characters there only (so you should use 
lowercase letters on the pattern, of course).

Did you try it?

Alessandro


Prakash Reddy K. L. V. wrote:
>
> Alessandro,
>
> This does not help. fn:lower-case will just convert the letters to 
> lower case.
> May be I was not clear in my earlier mail.
> I want to retrieve all nodes whose property has values like 
> "MyArtcilexxx", "MyARTicleyyy", "artcilezzzz" and so on.
> I want something like String.equalsIgnoreCase("article") .
>
> Regards,
> Prakash
>
> Alessandro Bologna wrote:
>> Yes,
>> Try using //*[jcr:like(fn:lower-case(@propertyName), '%article%')] 
>> Alessandro
>>
>>
>> Prakash Reddy K. L. V. wrote:
>>>
>>> Hi Alessandro,
>>>
>>> Thanks for your response.
>>> The query //*[jcr:like(@propertyName, '%article%')] seems to work 
>>> for me. But I have a problem here. It seems to be case sensitive.
>>> Is there a way to tell jackrabbit to ignore case??
>>>
>>> Regards,
>>> Prakash
>>>
>>>
>>> Alessandro Bologna wrote:
>>>> Hi,
>>>>
>>>> you can't search for substrings of the node name, but if you do 
>>>> store the node name in a property, then you can use either jcr:like 
>>>> or jcs:contains (not just "contains", the XPATH in Jackrabbit 
>>>> doesn't support it).
>>>>
>>>> So try:
>>>>     //*[jcr:contains(@propertyName,'article')]
>>>>    or:
>>>>     //*[jcr:like(@propertyName, '%article%')]
>>>>
>>>> Further reading here 
>>>> http://www.theserverside.com/tt/articles/article.tss?l=JCRPract  
>>>> and of course the JSR-170 specs.
>>>>
>>>> Hope it helps.
>>>> Alessandro
>>>>
>>>>
>>>>
>>>> Prakash Reddy K. L. V. wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I am using jackrabbit as my content repository.
>>>>> Is there a way to search for nodes whose name contains a 
>>>>> particular word using XPath?
>>>>> For example I want to search for all the nodes whose name contains 
>>>>> "article".
>>>>>
>>>>> I tried this query : /jcr:root/*article*
>>>>> This does not work.
>>>>>
>>>>> I also tried storing the name as property of the node and tried 
>>>>> this query :
>>>>> /jcr:root/*[@propertyName=''article"]
>>>>> This does not even get those nodes for which the value of the 
>>>>> property is "article".
>>>>>
>>>>> Is there any other way to achieve this ?
>>>>>
>>>>> Thanks,
>>>>> Prakash
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>


Re: Querying for nodes whose name contains "somepattern"

Posted by "Prakash Reddy K. L. V." <Pr...@Sun.COM>.
Hi Torgeir,

I am not querying any legacy data nor am I using any legacy system.
In my application, all the nodes are of the same type "nt:unstructured".
I want to search for those nodes whose property say "MyProperty" has the 
word "article" in its value.
All the values like "xxARTICLEzz" , "artiCLEyy", "article" should match.
I used this query //*[jcr:like(@MyProperty, '%article%')] .
But the problem with this is that while searching for the value, it does 
not ignore case.

Is there any way to achieve this??

Thanks,
Prakash

Torgeir Veimo wrote:
>
> On 15 Jan 2008, at 18:02, Prakash Reddy K. L. V. wrote:
>
>> This does not help. fn:lower-case will just convert the letters to 
>> lower case.
>> May be I was not clear in my earlier mail.
>> I want to retrieve all nodes whose property has values like 
>> "MyArtcilexxx", "MyARTicleyyy", "artcilezzzz" and so on.
>> I want something like String.equalsIgnoreCase("article") .
>
>
> If you have complete control over the node types, it might be easier 
> for you to query on node type. Are you querying legacy data moved from 
> a legacy backend, or using a legacy frontend with a new jcr backend?
>


Re: Querying for nodes whose name contains "somepattern"

Posted by Torgeir Veimo <to...@pobox.com>.
On 15 Jan 2008, at 18:02, Prakash Reddy K. L. V. wrote:

> This does not help. fn:lower-case will just convert the letters to  
> lower case.
> May be I was not clear in my earlier mail.
> I want to retrieve all nodes whose property has values like  
> "MyArtcilexxx", "MyARTicleyyy", "artcilezzzz" and so on.
> I want something like String.equalsIgnoreCase("article") .


If you have complete control over the node types, it might be easier  
for you to query on node type. Are you querying legacy data moved from  
a legacy backend, or using a legacy frontend with a new jcr backend?

-- 
Torgeir Veimo
torgeir@pobox.com




Re: Querying for nodes whose name contains "somepattern"

Posted by "Prakash Reddy K. L. V." <Pr...@Sun.COM>.
Alessandro,

This does not help. fn:lower-case will just convert the letters to lower 
case.
May be I was not clear in my earlier mail.
I want to retrieve all nodes whose property has values like 
"MyArtcilexxx", "MyARTicleyyy", "artcilezzzz" and so on.
I want something like String.equalsIgnoreCase("article") .

Regards,
Prakash

Alessandro Bologna wrote:
> Yes,
> Try using //*[jcr:like(fn:lower-case(@propertyName), '%article%')] 
> Alessandro
>
>
> Prakash Reddy K. L. V. wrote:
>>
>> Hi Alessandro,
>>
>> Thanks for your response.
>> The query //*[jcr:like(@propertyName, '%article%')] seems to work for 
>> me. But I have a problem here. It seems to be case sensitive.
>> Is there a way to tell jackrabbit to ignore case??
>>
>> Regards,
>> Prakash
>>
>>
>> Alessandro Bologna wrote:
>>> Hi,
>>>
>>> you can't search for substrings of the node name, but if you do 
>>> store the node name in a property, then you can use either jcr:like 
>>> or jcs:contains (not just "contains", the XPATH in Jackrabbit 
>>> doesn't support it).
>>>
>>> So try:
>>>     //*[jcr:contains(@propertyName,'article')]
>>>    or:
>>>     //*[jcr:like(@propertyName, '%article%')]
>>>
>>> Further reading here 
>>> http://www.theserverside.com/tt/articles/article.tss?l=JCRPract  and 
>>> of course the JSR-170 specs.
>>>
>>> Hope it helps.
>>> Alessandro
>>>
>>>
>>>
>>> Prakash Reddy K. L. V. wrote:
>>>>
>>>> Hi,
>>>>
>>>> I am using jackrabbit as my content repository.
>>>> Is there a way to search for nodes whose name contains a particular 
>>>> word using XPath?
>>>> For example I want to search for all the nodes whose name contains 
>>>> "article".
>>>>
>>>> I tried this query : /jcr:root/*article*
>>>> This does not work.
>>>>
>>>> I also tried storing the name as property of the node and tried 
>>>> this query :
>>>> /jcr:root/*[@propertyName=''article"]
>>>> This does not even get those nodes for which the value of the 
>>>> property is "article".
>>>>
>>>> Is there any other way to achieve this ?
>>>>
>>>> Thanks,
>>>> Prakash
>>>>
>>>>
>>>>
>>>
>>
>


Re: Querying for nodes whose name contains "somepattern"

Posted by Alessandro Bologna <al...@gmail.com>.
Yes,
Try using //*[jcr:like(fn:lower-case(@propertyName), '%article%')] 
Alessandro


Prakash Reddy K. L. V. wrote:
>
> Hi Alessandro,
>
> Thanks for your response.
> The query //*[jcr:like(@propertyName, '%article%')] seems to work for 
> me. But I have a problem here. It seems to be case sensitive.
> Is there a way to tell jackrabbit to ignore case??
>
> Regards,
> Prakash
>
>
> Alessandro Bologna wrote:
>> Hi,
>>
>> you can't search for substrings of the node name, but if you do store 
>> the node name in a property, then you can use either jcr:like or 
>> jcs:contains (not just "contains", the XPATH in Jackrabbit doesn't 
>> support it).
>>
>> So try:
>>     //*[jcr:contains(@propertyName,'article')]
>>    or:
>>     //*[jcr:like(@propertyName, '%article%')]
>>
>> Further reading here 
>> http://www.theserverside.com/tt/articles/article.tss?l=JCRPract  and 
>> of course the JSR-170 specs.
>>
>> Hope it helps.
>> Alessandro
>>
>>
>>
>> Prakash Reddy K. L. V. wrote:
>>>
>>> Hi,
>>>
>>> I am using jackrabbit as my content repository.
>>> Is there a way to search for nodes whose name contains a particular 
>>> word using XPath?
>>> For example I want to search for all the nodes whose name contains 
>>> "article".
>>>
>>> I tried this query : /jcr:root/*article*
>>> This does not work.
>>>
>>> I also tried storing the name as property of the node and tried this 
>>> query :
>>> /jcr:root/*[@propertyName=''article"]
>>> This does not even get those nodes for which the value of the 
>>> property is "article".
>>>
>>> Is there any other way to achieve this ?
>>>
>>> Thanks,
>>> Prakash
>>>
>>>
>>>
>>
>


Re: Querying for nodes whose name contains "somepattern"

Posted by "Prakash Reddy K. L. V." <Pr...@Sun.COM>.
Hi Alessandro,

Thanks for your response.
The query //*[jcr:like(@propertyName, '%article%')] seems to work for 
me. But I have a problem here. It seems to be case sensitive.
Is there a way to tell jackrabbit to ignore case??

Regards,
Prakash


Alessandro Bologna wrote:
> Hi,
> 
> you can't search for substrings of the node name, but if you do store 
> the node name in a property, then you can use either jcr:like or 
> jcs:contains (not just "contains", the XPATH in Jackrabbit doesn't 
> support it).
> 
> So try:
>     //*[jcr:contains(@propertyName,'article')]
>    or:
>     //*[jcr:like(@propertyName, '%article%')]
> 
> Further reading here 
> http://www.theserverside.com/tt/articles/article.tss?l=JCRPract  and of 
> course the JSR-170 specs.
> 
> Hope it helps.
> Alessandro
> 
> 
> 
> Prakash Reddy K. L. V. wrote:
>>
>> Hi,
>>
>> I am using jackrabbit as my content repository.
>> Is there a way to search for nodes whose name contains a particular 
>> word using XPath?
>> For example I want to search for all the nodes whose name contains 
>> "article".
>>
>> I tried this query : /jcr:root/*article*
>> This does not work.
>>
>> I also tried storing the name as property of the node and tried this 
>> query :
>> /jcr:root/*[@propertyName=''article"]
>> This does not even get those nodes for which the value of the property 
>> is "article".
>>
>> Is there any other way to achieve this ?
>>
>> Thanks,
>> Prakash
>>
>>
>>
> 


Re: Querying for nodes whose name contains "somepattern"

Posted by Alessandro Bologna <al...@gmail.com>.
Hi,

you can't search for substrings of the node name, but if you do store 
the node name in a property, then you can use either jcr:like or 
jcs:contains (not just "contains", the XPATH in Jackrabbit doesn't 
support it).

So try:
     //*[jcr:contains(@propertyName,'article')]
    or:
     //*[jcr:like(@propertyName, '%article%')]

Further reading here 
http://www.theserverside.com/tt/articles/article.tss?l=JCRPract  and of 
course the JSR-170 specs.

Hope it helps.
Alessandro



Prakash Reddy K. L. V. wrote:
>
> Hi,
>
> I am using jackrabbit as my content repository.
> Is there a way to search for nodes whose name contains a particular 
> word using XPath?
> For example I want to search for all the nodes whose name contains 
> "article".
>
> I tried this query : /jcr:root/*article*
> This does not work.
>
> I also tried storing the name as property of the node and tried this 
> query :
> /jcr:root/*[@propertyName=''article"]
> This does not even get those nodes for which the value of the property 
> is "article".
>
> Is there any other way to achieve this ?
>
> Thanks,
> Prakash
>
>
>