You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Phillip Rhodes <sp...@rhoderunner.com> on 2007/04/26 04:43:39 UTC

contains search starting from specific node?

I am trying to do a contains xpath search, and restrict the search to a node (and it's children). 

Doing this search works, but does not require results to be in the "myfolder" node
//*[jcr:contains(.,'test')]

The above search returns a node that I have added and the node.getPath() function returns a value of:
/myfolder/a pdf/jcr:content

This search, while it does not error out, it does not return any results:
//myfolder/*[jcr:contains(.,'test')]

I have tried several variants of my search syntax.  Most of my tries have resulted in query parser errors.

Is it possible to do this type of search?  Can someone give me a hint on the syntax?

Thank you.

BTW, i have hessian/jackrabbit running pretty good right now.  It's so cool, I'm pysched that my app is working, the coolest part is that I can do image uploads, searching pdf's, and I only need 2 jars (hessian and my pojo stuff).





Re: contains search starting from specific node?

Posted by Marcel Reutegger <ma...@gmx.net>.
Hi Philipp,

Phillip Rhodes wrote:
> I am trying to do a contains xpath search, and restrict the search to a node
> (and it's children).
> 
> Doing this search works, but does not require results to be in the "myfolder"
> node //*[jcr:contains(.,'test')]
> 
> The above search returns a node that I have added and the node.getPath()
> function returns a value of: /myfolder/a pdf/jcr:content
> 
> This search, while it does not error out, it does not return any results: 
> //myfolder/*[jcr:contains(.,'test')]

this is because the jcr:contains matches the nt:resource node (the one named 
jcr:content) and the path without the predicate selects the nt:file nodes. thus 
the intersection is always empty.

/jcr:root/myfolder/*[jcr:contains(jcr:content, 'test')]

or if you want to find files in any folder called myfolder, not just under the 
root node:

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

regards
  marcel