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/14 21:15:46 UTC

Query mixin properties but also pull back nt:file information

Is there any way to query my custom mixin (hfs:file) and still be able to
pull back the default jcr:content information?

The default query (which searches the entire node contents and all
properties):

	//element(*, nt:file)[jcr:contains(jcr:content, 'text to
query')]/rep:excerpt(.)

The query I am using (which searches only the @hfs:description and
@hfs:formname priperties):

	//element(*, hfs:file)[jcr:contains(@hfs:description, 'text to
query') or jcr:contains(@hfs:formname, 'text to query')]/(@hfs:description |
@hfs:formname)

I also want to be able to search on jcr:content and return the same
information that the default search returns, plus my @hfs:description and
@hfs:fromname values, if possible.


Best Regards,

Michael Shoener
Support Staff
Software Application Services, Inc.



Re: Query mixin properties but also pull back nt:file information

Posted by Alexander Klimetschek <ak...@day.com>.
On Mon, Sep 14, 2009 at 21:15, Michael Shoener
<ms...@softwareapps.net> wrote:
> Is there any way to query my custom mixin (hfs:file) and still be able to
> pull back the default jcr:content information?
>
> The default query (which searches the entire node contents and all
> properties):
>
>        //element(*, nt:file)[jcr:contains(jcr:content, 'text to
> query')]/rep:excerpt(.)
>
> The query I am using (which searches only the @hfs:description and
> @hfs:formname priperties):
>
>        //element(*, hfs:file)[jcr:contains(@hfs:description, 'text to
> query') or jcr:contains(@hfs:formname, 'text to query')]/(@hfs:description |
> @hfs:formname)
>
> I also want to be able to search on jcr:content and return the same
> information that the default search returns, plus my @hfs:description and
> @hfs:fromname values, if possible.

Do you mean you want to get both the excerpt (the rep:excerpt() in
your default query) and the single properties you mention?

In this case you simply run

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

use the row iterator in the results and fetch both the properties via
row.getValue("hfs:description") and the excerpt via
row.getValue("rep:excerpt(.)"). The rep:excerpt function can be used
in both places - in the query and on the result set.

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com