You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Pankaj Gupta <pg...@fluent.com> on 2006/02/27 16:37:35 UTC

Search question

Hi,

I need to add a functionality that returns all nodes whose name matches 
a given pattern. For example, find all nodes whose name starts with 
"foo". How can I formulate such query using Jackrabbit's XPath. The path 
constraints don't allow any wildcards and I couldn't find a way of 
including the node name in the property constraints. XPath has functions 
such as name() and local-name() that can be used in the predicate 
expressions but they are not supported by the JCR spec.

The only workaround that I could think of was to add name as another 
property of the node. But this is redundant and I was hoping for a 
better solution.

Thanks,
Pankaj


Re: Search question

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

the node name is also added to the fulltext index of the node. That 
means jcr:contains() will also match the node name but of course also 
values of all other properties. If you have a node structure like this:

+ foo
   + bar
   + foobar

and and a query like this:
//*[jcr:contains(.,'foo*')]

it will return /foo and /foobar.
(And if /bar had a property value that matches 'foo*' it would also be 
included in the query result)

but keep in mind that fulltext indexing the node name is not specified 
in jsr-170 and an implementation specific feature of jackrabbit.

I'm currently quite busy with other development task, but I hope to add 
more XPath functions in a future release of jackrabbit.

regards
  marcel

Pankaj Gupta wrote:
> Hi,
> 
> I need to add a functionality that returns all nodes whose name matches 
> a given pattern. For example, find all nodes whose name starts with 
> "foo". How can I formulate such query using Jackrabbit's XPath. The path 
> constraints don't allow any wildcards and I couldn't find a way of 
> including the node name in the property constraints. XPath has functions 
> such as name() and local-name() that can be used in the predicate 
> expressions but they are not supported by the JCR spec.
> 
> The only workaround that I could think of was to add name as another 
> property of the node. But this is redundant and I was hoping for a 
> better solution.
> 
> Thanks,
> Pankaj
> 
>