You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Michael Shoener <ms...@softwareapps.net> on 2009/09/11 18:46:48 UTC
Query syntax comparing against multiple property values
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".
I tried the following in Xpath but it does not work:
//element(*, hfs:file)/(@hfs:description |
@hfs:formname)[jcr:contains(., 'testing')]
What am I missing in my query to make it not return any records?
Best Regards,
Michael Shoener
Support Staff
Software Application Services, Inc.
RE: Query syntax comparing against multiple property values
Posted by Michael Shoener <ms...@softwareapps.net>.
Thanks I just figured it out before I received this email ;-)
Best Regards,
Michael Shoener
Support Staff
Software Application Services, Inc.
-----Original Message-----
From: Alexander Klimetschek [mailto:aklimets@day.com]
Sent: Monday, September 14, 2009 11:09 AM
To: users@jackrabbit.apache.org
Subject: Re: Query syntax comparing against multiple property values
On Fri, Sep 11, 2009 at 18:46, Michael Shoener <ms...@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.
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
Re: Query syntax comparing against multiple property values
Posted by Alexander Klimetschek <ak...@day.com>.
On Fri, Sep 11, 2009 at 18:46, Michael Shoener
<ms...@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.
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
RE: Query syntax comparing against multiple property values
Posted by Michael Shoener <ms...@softwareapps.net>.
Tried it and same result, nothing returned.
Any other ideas?
Best Regards,
Michael Shoener
Support Staff
Software Application Services, Inc.
-----Original Message-----
From: Savvas Triantafyllou [mailto:savvas.triantafyllou@gmail.com]
Sent: Saturday, September 12, 2009 12:53 PM
To: users@jackrabbit.apache.org
Subject: Re: Query syntax comparing against multiple property values
Hi,
have you tried
//element(*, hfs:file)[jcr:contains(., 'testing')]/(@hfs:description |
@hfs:formname)
BR,
Savvas
2009/9/11 Michael Shoener <ms...@softwareapps.net>
> 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".
>
> I tried the following in Xpath but it does not work:
>
> //element(*, hfs:file)/(@hfs:description |
> @hfs:formname)[jcr:contains(., 'testing')]
>
>
> What am I missing in my query to make it not return any records?
>
>
> Best Regards,
>
> Michael Shoener
> Support Staff
> Software Application Services, Inc.
>
>
>
Re: Query syntax comparing against multiple property values
Posted by Savvas Triantafyllou <sa...@gmail.com>.
Hi,
have you tried
//element(*, hfs:file)[jcr:contains(., 'testing')]/(@hfs:description |
@hfs:formname)
BR,
Savvas
2009/9/11 Michael Shoener <ms...@softwareapps.net>
> 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".
>
> I tried the following in Xpath but it does not work:
>
> //element(*, hfs:file)/(@hfs:description |
> @hfs:formname)[jcr:contains(., 'testing')]
>
>
> What am I missing in my query to make it not return any records?
>
>
> Best Regards,
>
> Michael Shoener
> Support Staff
> Software Application Services, Inc.
>
>
>