jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <aklim...@day.com>
Subject Re: Query syntax comparing against multiple property values
Date Mon, 14 Sep 2009 15:08:46 GMT
On Fri, Sep 11, 2009 at 18:46, Michael Shoener
<mshoener@softwareapps.net> wrote:
> I am trying to figure out the correct Xpath query for the following SQL
> query:
>        SELECT hfs:description, hfs:formname FROM hfs:file WHERE CONTAINS(.,
> 'testing')
> The above query returns all records where either the hfs:description or
> hfs:formname contains the value "testing".

This will return all nodes that contain 'testing' somewhere (depending
on the text extraction). You have to specify the properties in the
contains method explicitly if you want to search only inside
properties and not the whole node. The properties in the select part
are only for selecting/restricting the result set, they have no
influence on the where clause. In Jackrabbit, the result set will
always be nodes.

For xpath, this would look like this:

//element(*, hfs:file)[jcr:contains(@hfs:description, 'testing') or
jcr:contains(@hfs:formname, 'testing')]

The result will contain nodes anyway, so to get those properties you
have to call node.getProperty("hfs:description") or
row.getValue("hfs:description") for each result node/row.


Alexander Klimetschek

View raw message