On Thu, Oct 1, 2009 at 16:06, Simon Gaeremynck <[email protected]> wrote:
> I am trying to do a query where I want to get a set of nodes by matching
> their names to a string.
> For example:
> Repository:
> /sites/mysite/_files/WeekI_Day1
> /sites/mysite/_files/WeekI_Day2
> /sites/mysite/_files/WeekII_Day1
> /sites/mysite/_files/WeekII_Day2
>
> I would like to be able to do a query so I can get the two WeekI nodes..
>
> I have tried the following:
> //sites/mysite/_files//*[fn:name()="WeekI*"] order by @jcr:created
> descending
> //sites/mysite/_files//*[jcr:name="WeekI*"] order by @jcr:created descending
>
> These 2 only seem to work if I provide the full node name, which is not what
> I want.

JCR 1.0 does not support a wildcard query for node names, ie.
fn:name() can only be used for exact matches.

> //sites/mysite/_files//*[jcr:contains(., "*WeekI*"] order by @jcr:created
> descending
> This one works fine for properties who contain WeekI but doesn't match the
> node name.

jcr:contains(., "Week") should include matches on the nodename, but it
will of course also include other full text matches, hence it is not
useful for distinctive search queries.

> Does anybody have any other suggestions?

a) put the "week" stuff into properties and query via
[jcr:like(@property, '%Week%')]
b) navigation: find the parent folder and then filter nodes by name
using getNodes(String namePattern) [1]

[1] 
http://www.day.com/maven/jsr170/javadocs/jcr-2.0/javax/jcr/Node.html#getNodes(java.lang.String)

Regards,
Alex

-- 
Alexander Klimetschek
[email protected]

Reply via email to