You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Mohinder Singh <ms...@swri.org> on 2009/10/01 17:01:33 UTC

Querying multi-valued properties

Hi,
I am using following query to get the multi-valued property 'keywords' from
'partialKeywords' (in order to achieve 'Google suggest' like behavior):

"//element(*, sw:resource)/@sw:keywords[jcr:like(@sw:keywords, '%" +
partialKeyword + "%')]";

How can I now retrieve multi-valued 'keywords' quickly from the query
result?

Thanks,
Mohinder



Re: Querying multi-valued properties

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

On Thu, Oct 1, 2009 at 17:01, Mohinder Singh <ms...@swri.org> wrote:
> Hi,
> I am using following query to get the multi-valued property 'keywords' from
> 'partialKeywords' (in order to achieve 'Google suggest' like behavior):
>
> "//element(*, sw:resource)/@sw:keywords[jcr:like(@sw:keywords, '%" +
> partialKeyword + "%')]";
>
> How can I now retrieve multi-valued 'keywords' quickly from the query
> result?

you get the NodeIterator from the query result and then get the
property values using the regular API:
node.getProperty('sw:keywords').getValues()

please note that jcr:like with wildcard prefixes might be slow.
Specifically if you have lots of distinct values for that property. I
suggest you use jcr:contains if possible.

regards
 marcel