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/25 16:16:29 UTC

Query mixin and nt:resource nodes

I have the following query:

	//element(*, hfs:fileInfo)[jcr:contains(., 'example')]

It returns all matching nodes because it searches on all properties AND the
file content itself.

I really only want to query on the file contents alone (the data contained
in the file) so I tried the following but it does not return any values:

	//element(*, hfs:fileInfo)[jcr:contains(jcr:data, 'example')]

Am I missing something in my query?


Best Regards,

Michael Shoener
Support Staff
Software Application Services, Inc.



Re: Query mixin and nt:resource nodes

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

On Thu, Oct 1, 2009 at 15:08, Michael Shoener <ms...@softwareapps.net> wrote:
> Should I be adding the mixin to the parent nt:file node?

if you need to do fulltext searches only on the file content
(excluding the description) this is a good option.

> If so, then what
> node type do I search on in my query?

you search for nt:file.

> I have a custom mixin defined called "hfs:fileInfo". Is has several
> properties (description, entered, modified).

btw, what's the use of entered and modified? aren't those already
covered with the predefined properties jcr:created (on nt:file) and
jcr:lastModified (on nt:resource) ?

> What would the query look like to search on both the binary file data and my
> custom mixin properties?

see examples in my previous post.

regards
 marcel

RE: Query mixin and nt:resource nodes

Posted by Michael Shoener <ms...@softwareapps.net>.
I haven't touched any of the indexing configuration settings and from what I
have seen the default is to index the basic file types I am storing in the
repository.

What I am trying to do is have my query search on both the binary file data
and my custom mixin which is added to the nt:resource node.

Should I be adding the mixin to the parent nt:file node? If so, then what
node type do I search on in my query?

I have a custom mixin defined called "hfs:fileInfo". Is has several
properties (description, entered, modified).

What would the query look like to search on both the binary file data and my
custom mixin properties?


Best Regards,

Michael Shoener
Support Staff
Software Application Services, Inc.


-----Original Message-----
From: mreutegg@day.com [mailto:mreutegg@day.com] On Behalf Of Marcel
Reutegger
Sent: Thursday, October 01, 2009 5:17 AM
To: users@jackrabbit.apache.org
Subject: Re: Query mixin and nt:resource nodes

Hi,

On Mon, Sep 28, 2009 at 23:54, Michael Shoener <ms...@softwareapps.net>
wrote:
> I tried your suggestion to use @jcr:data and still get nothing.

see: http://jackrabbit.apache.org/frequently-asked-questions.html

"Why doesn't //*[jcr:contains(@jcr:data, 'foo')] return matches for binary
content?"

> What exactly does the "." in the jcr:contains search in relation to 
> the node?

it means that the XPath context node is searched using the
jcr:contains() function. In jackrabbit jcr:contains will search all
properties on that node unless otherwise configured in the indexing
configuration.

see: http://wiki.apache.org/jackrabbit/IndexingConfiguration

> Any other suggestions?

you could separate the resource from the file. e.g. have the description
property on a node that is distinct from the node where you have the
jcr:data on.

using built in node types that would be:

//element(*, nt:file)[jcr:contains(jcr:content, 'example')]

or if you also want to search on description:

//element(*, nt:file)[jcr:contains(@description, 'example' or
jcr:contains(jcr:content, 'example')]

(assuming you have a custom node type that extends from nt:file and allows
you to set @description)

regards
 marcel


Re: Query mixin and nt:resource nodes

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

On Mon, Sep 28, 2009 at 23:54, Michael Shoener
<ms...@softwareapps.net> wrote:
> I tried your suggestion to use @jcr:data and still get nothing.

see: http://jackrabbit.apache.org/frequently-asked-questions.html

"Why doesn't //*[jcr:contains(@jcr:data, 'foo')] return matches for
binary content?"

> What exactly does the "." in the jcr:contains search in relation to the
> node?

it means that the XPath context node is searched using the
jcr:contains() function. In jackrabbit jcr:contains will search all
properties on that node unless otherwise configured in the indexing
configuration.

see: http://wiki.apache.org/jackrabbit/IndexingConfiguration

> Any other suggestions?

you could separate the resource from the file. e.g. have the
description property on a node that is distinct from the node where
you have the jcr:data on.

using built in node types that would be:

//element(*, nt:file)[jcr:contains(jcr:content, 'example')]

or if you also want to search on description:

//element(*, nt:file)[jcr:contains(@description, 'example' or
jcr:contains(jcr:content, 'example')]

(assuming you have a custom node type that extends from nt:file and
allows you to set @description)

regards
 marcel

RE: Query mixin and nt:resource nodes

Posted by Michael Shoener <ms...@softwareapps.net>.
I tried your suggestion to use @jcr:data and still get nothing.

I wanted to make sure it was not a file type problem so I even tried using a
plain text file.

If I use:
	 //element(*, hfs:fileInfo)[jcr:contains(., 'example')]

It works but if I use :

	//element(*, hfs:fileInfo)[jcr:contains(@jcr:data, 'example')] 
			or

	 //element(*, hfs:fileInfo)[jcr:contains(jcr:data, 'example')]

It does NOT work.

I haven't changed any of the default text extractors, so that’s not the
problem.

What exactly does the "." in the jcr:contains search in relation to the
node?

Would the source code show me and in what source file would I look?

Any other suggestions?


Best Regards,

Michael Shoener
Support Staff
Software Application Services, Inc.


-----Original Message-----
From: Alexander Klimetschek [mailto:aklimets@day.com] 
Sent: Monday, September 28, 2009 8:11 AM
To: users@jackrabbit.apache.org
Subject: Re: Query mixin and nt:resource nodes

On Fri, Sep 25, 2009 at 16:16, Michael Shoener <ms...@softwareapps.net>
wrote:
> I have the following query:
>
>        //element(*, hfs:fileInfo)[jcr:contains(., 'example')]
>
> It returns all matching nodes because it searches on all properties 
> AND the file content itself.
>
> I really only want to query on the file contents alone (the data 
> contained in the file) so I tried the following but it does not return any
values:
>
>        //element(*, hfs:fileInfo)[jcr:contains(jcr:data, 'example')]
>
> Am I missing something in my query?

Did you try jcr:contains(@jcr:data, 'example') ?

And for binary data the extraction depends on the file type and if there is
an appropriate text extractor available. Finally, if it's a larger document
(or many text extractions have to happen at the same time), the extraction
is queued and not immediately available after session.save().

Regards,
Alex

--
Alexander Klimetschek
alexander.klimetschek@day.com


Re: Query mixin and nt:resource nodes

Posted by Alexander Klimetschek <ak...@day.com>.
On Fri, Sep 25, 2009 at 16:16, Michael Shoener
<ms...@softwareapps.net> wrote:
> I have the following query:
>
>        //element(*, hfs:fileInfo)[jcr:contains(., 'example')]
>
> It returns all matching nodes because it searches on all properties AND the
> file content itself.
>
> I really only want to query on the file contents alone (the data contained
> in the file) so I tried the following but it does not return any values:
>
>        //element(*, hfs:fileInfo)[jcr:contains(jcr:data, 'example')]
>
> Am I missing something in my query?

Did you try jcr:contains(@jcr:data, 'example') ?

And for binary data the extraction depends on the file type and if
there is an appropriate text extractor available. Finally, if it's a
larger document (or many text extractions have to happen at the same
time), the extraction is queued and not immediately available after
session.save().

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com