You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Alexander Saar <al...@googlemail.com> on 2011/02/05 16:34:00 UTC

XPath Question

Hi all,

I'd like to find all nodes of a certain type that have a sub node at some
level with a certain property that contains a value I'm searching for. The
following query works if I have a sub node two levels under the
nt:unstructured node:

/jcr:root//element(*, nt:unstructured)[jcr:contains(./*/*/@text, 'test')]
order by @jcr:score

But I don't know the exact level. So I tried the following:

/jcr:root//element(*, nt:unstructured)[jcr:contains(.//@text, 'test')] order
by @jcr:score

This query doesn't return any hits. But I'd expect the same result set.

Any ideas what I'm doing wrong?

Thanks
Alex

Re: XPath Question

Posted by Alexander Klimetschek <ak...@adobe.com>.
On 06.02.11 19:39, "Alexander Saar" <al...@googlemail.com> wrote:
>thanks for the reply. If sub levels do not work then why is this query
>working:
>
>/jcr:root//element(*, nt:unstructured)[jcr:contains(./*/*/@text, 'test')]
>order by @jcr:score

You can only have fixed relative paths inside the jcr:contains, such as
"jcr:content/foo/@text", and probably that includes wildcards. But you
can't use any Xpath axis here, i.e. not "//".

>When I try index aggregates it seems that I cannot search for specific
>properties anymore. At least jcr:contains(@property, 'test') is not
>returning any results but jcr:contains(., 'test') does. Is this expected
>due
>to the aggregation?

I don't know exactly, but I think if you define an index-rule, you need to
explicitly name all properties or use a wildcard matcher:

<property isRegexp="true">.*:.*</property>

But not sure if the same holds true for aggregates.

Regards,
Alex

-- 
Alexander Klimetschek
Developer // Adobe (Day) // Berlin - Basel





Re: XPath Question

Posted by Alexander Saar <al...@googlemail.com>.
Hi,

thanks for the reply. If sub levels do not work then why is this query
working:

/jcr:root//element(*, nt:unstructured)[jcr:contains(./*/*/@text, 'test')]
order by @jcr:score

When I try index aggregates it seems that I cannot search for specific
properties anymore. At least jcr:contains(@property, 'test') is not
returning any results but jcr:contains(., 'test') does. Is this expected due
to the aggregation?

Haven't looked into joins yet but will give it a shot.

Thanks
Alex


2011/2/5 François Cassistat <f....@maya-systems.com>

> It does not work on sub levels.
>
> jcr:contains(@property, 'test') is ok
> jcr:contains(., 'test') is ok
> jcr:contains(path/to/@property, 'test') is not ok
>
> I've managed to make this work with a join in JQOM.
>
> In XPath, you may look at the Index Aggregates section in
> IndexingConfiguration in the wiki to includes content of descendant nodes on
> a parent node.
> http://wiki.apache.org/jackrabbit/IndexingConfiguration
>
> Cheers,
>
>
> François
>
>
> Le 2011-02-05 à 10:34, Alexander Saar a écrit :
>
> > Hi all,
> >
> > I'd like to find all nodes of a certain type that have a sub node at some
> > level with a certain property that contains a value I'm searching for.
> The
> > following query works if I have a sub node two levels under the
> > nt:unstructured node:
> >
> > /jcr:root//element(*, nt:unstructured)[jcr:contains(./*/*/@text, 'test')]
> > order by @jcr:score
> >
> > But I don't know the exact level. So I tried the following:
> >
> > /jcr:root//element(*, nt:unstructured)[jcr:contains(.//@text, 'test')]
> order
> > by @jcr:score
> >
> > This query doesn't return any hits. But I'd expect the same result set.
> >
> > Any ideas what I'm doing wrong?
> >
> > Thanks
> > Alex
>
>


-- 
Alexander Saar

Mobile: +49.177.5985437
E-Mail: alexander.saar@gmail.com
Web:    http://alexander.saar.googlepages.com
Blog:   http://weblogs.goshaky.com/weblogs/saar/

Re: XPath Question

Posted by Alexander Klimetschek <ak...@adobe.com>.
On 05.02.11 19:23, "François Cassistat" <f....@maya-systems.com>
wrote:
>jcr:contains(path/to/@property, 'test') is not ok

Yes, this should work.

Regards,
Alex

-- 
Alexander Klimetschek
Developer // Adobe (Day) // Berlin - Basel


Re: XPath Question

Posted by François Cassistat <f....@maya-systems.com>.
It does not work on sub levels.

jcr:contains(@property, 'test') is ok
jcr:contains(., 'test') is ok
jcr:contains(path/to/@property, 'test') is not ok

I've managed to make this work with a join in JQOM.

In XPath, you may look at the Index Aggregates section in IndexingConfiguration in the wiki to includes content of descendant nodes on a parent node.
http://wiki.apache.org/jackrabbit/IndexingConfiguration

Cheers,


François


Le 2011-02-05 à 10:34, Alexander Saar a écrit :

> Hi all,
> 
> I'd like to find all nodes of a certain type that have a sub node at some
> level with a certain property that contains a value I'm searching for. The
> following query works if I have a sub node two levels under the
> nt:unstructured node:
> 
> /jcr:root//element(*, nt:unstructured)[jcr:contains(./*/*/@text, 'test')]
> order by @jcr:score
> 
> But I don't know the exact level. So I tried the following:
> 
> /jcr:root//element(*, nt:unstructured)[jcr:contains(.//@text, 'test')] order
> by @jcr:score
> 
> This query doesn't return any hits. But I'd expect the same result set.
> 
> Any ideas what I'm doing wrong?
> 
> Thanks
> Alex