You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Torgeir Veimo <to...@netenviron.com> on 2012/03/28 14:46:05 UTC
jcr:contains query issues
I'm trying to query (using xpath xyntax) for a number of nodes with
sorting based on how many tags on each node matches a set of tags.
I'm currently trying to do this using
//element(*, nt:base)[jcr:contains(@tagproperty, 'tag1 tag2 tag3')]
order by @jcr:score
but it doesn't work very well. Instead I can use
//element(*, nt:base)[jcr:contains(@tagproperty, 'tag1') or
jcr:contains(@tagproperty, 'tag2') or jcr:contains(@tagproperty,
'tag3')] order by @jcr:score
but the query string can potentially become very large.
Additionally, I'm also trying to include nodes that doesn't match any
of the tags, but just sort them such that they end up below the
matching nodes. This requires an additional 'dummy match', but I'm
having trouble letting this dummy match have a lower boost than the
jcr:contains, even when I boost the contains, (all nodes have a name
property):
//element(*, nt:base)[(jcr:contains(@tagproperty, 'tag1^10') or
jcr:contains(@tagproperty, 'tag^10') or jcr:contains(@tagproperty,
'tag3^10') or @name)] order by @jcr:score
Is there a better way of doing this?
--
-Tor
Re: jcr:contains query issues
Posted by Alexander Klimetschek <ak...@adobe.com>.
On 28.03.2012, at 05:46, Torgeir Veimo wrote:
> I'm trying to query (using xpath xyntax) for a number of nodes with
> sorting based on how many tags on each node matches a set of tags.
>
> I'm currently trying to do this using
>
> //element(*, nt:base)[jcr:contains(@tagproperty, 'tag1 tag2 tag3')]
> order by @jcr:score
>
> but it doesn't work very well.
If you use a multi-value property, you can do:
//*[@tagproperty = "tag1" or @tagproperty = "tag2" or @tagproperty = "tag3"]
For multi-value properties, the operator "=" matches if at least one value matches.
I think the first terms get a higher score. Not sure how to handle your dummy match score though.
Cheers,
Alex