You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Kristof Taveirne <kr...@gmail.com> on 2009/08/15 20:38:45 UTC

How to Filter on a Collection

Hi,

I'm just starting out using jackrabbit and I'm running into something that's
probably a newbie question but anyway here I go.

I'm using OCM and I have this class which represents some content.
The content also has some metadata which is stored in List of MetaData
objects.
MetaData object is a Key/Value pair.

This list is annotated with the @Collection annotation.

I want to search this content based on some properties but then I want to
select the apropriate version of the content.
For example "Show content about X but with language="ENGLISH" AND
childproof=true"

This would return English content with images that is OK to show to
children.
language and childproof are NOT fields in the Content object but are keys in
MetaData objects.

Here is the structure of my class
Content
  - code
  - title
  - subtitle
  - text
  - image
  - meta
    - metaData ( key: lang, value: "EN")
    - metaData ( key: childproof, value: "true")


code represents an identifier for the content. this means the dutch version
and the english version have the same code.
I know the code, and I want to filter out the childproof english version.

filter.addEqualTo("code","1F3CDX4") ... that was easy

I would like to do the query on repository level, but ofcourse I could just
fetch all Content objects with that code, and filter manually ....

Can somebody help me with this?

Thanks!

Greetings,
K.

Re: How to Filter on a Collection

Posted by Kristof Taveirne <kr...@gmail.com>.
Hi Christophe,

Works great! thanks!

greetings,
Kristof

On Tue, Aug 18, 2009 at 12:29 PM, Christophe Lombart <
christophe.lombart@gmail.com> wrote:

> Hi Kristof,
>
> Sorry for the delay.
>
> The OCM query manager is not yet supporting queries with collection
> element properties but you can search content objects with a native
> JCR query (see ObjectContentManager.getObjects(String query, String
> language) or ObjectContentManager.getObjectIterator(String query,
> String language)).
>
> I'm just wondering if you can use the following JCR statement (or
> something similar) :
> //element(*, nt:unstructured) [@code='code1' and meta/*/@lang= 'FR'  ]
>
> br,
> Christophe
>
>
> 2009/8/15 Kristof Taveirne <kr...@gmail.com>:
> > Hi,
> >
> > I'm just starting out using jackrabbit and I'm running into something
> that's
> > probably a newbie question but anyway here I go.
> >
> > I'm using OCM and I have this class which represents some content.
> > The content also has some metadata which is stored in List of MetaData
> > objects.
> > MetaData object is a Key/Value pair.
> >
> > This list is annotated with the @Collection annotation.
> >
> > I want to search this content based on some properties but then I want to
> > select the apropriate version of the content.
> > For example "Show content about X but with language="ENGLISH" AND
> > childproof=true"
> >
> > This would return English content with images that is OK to show to
> > children.
> > language and childproof are NOT fields in the Content object but are keys
> in
> > MetaData objects.
> >
> > Here is the structure of my class
> > Content
> >  - code
> >  - title
> >  - subtitle
> >  - text
> >  - image
> >  - meta
> >    - metaData ( key: lang, value: "EN")
> >    - metaData ( key: childproof, value: "true")
> >
> >
> > code represents an identifier for the content. this means the dutch
> version
> > and the english version have the same code.
> > I know the code, and I want to filter out the childproof english version.
> >
> > filter.addEqualTo("code","1F3CDX4") ... that was easy
> >
> > I would like to do the query on repository level, but ofcourse I could
> just
> > fetch all Content objects with that code, and filter manually ....
> >
> > Can somebody help me with this?
> >
> > Thanks!
> >
> > Greetings,
> > K.
> >
>

Re: How to Filter on a Collection

Posted by Christophe Lombart <ch...@gmail.com>.
Hi Kristof,

Sorry for the delay.

The OCM query manager is not yet supporting queries with collection
element properties but you can search content objects with a native
JCR query (see ObjectContentManager.getObjects(String query, String
language) or ObjectContentManager.getObjectIterator(String query,
String language)).

I'm just wondering if you can use the following JCR statement (or
something similar) :
//element(*, nt:unstructured) [@code='code1' and meta/*/@lang= 'FR'  ]

br,
Christophe


2009/8/15 Kristof Taveirne <kr...@gmail.com>:
> Hi,
>
> I'm just starting out using jackrabbit and I'm running into something that's
> probably a newbie question but anyway here I go.
>
> I'm using OCM and I have this class which represents some content.
> The content also has some metadata which is stored in List of MetaData
> objects.
> MetaData object is a Key/Value pair.
>
> This list is annotated with the @Collection annotation.
>
> I want to search this content based on some properties but then I want to
> select the apropriate version of the content.
> For example "Show content about X but with language="ENGLISH" AND
> childproof=true"
>
> This would return English content with images that is OK to show to
> children.
> language and childproof are NOT fields in the Content object but are keys in
> MetaData objects.
>
> Here is the structure of my class
> Content
>  - code
>  - title
>  - subtitle
>  - text
>  - image
>  - meta
>    - metaData ( key: lang, value: "EN")
>    - metaData ( key: childproof, value: "true")
>
>
> code represents an identifier for the content. this means the dutch version
> and the english version have the same code.
> I know the code, and I want to filter out the childproof english version.
>
> filter.addEqualTo("code","1F3CDX4") ... that was easy
>
> I would like to do the query on repository level, but ofcourse I could just
> fetch all Content objects with that code, and filter manually ....
>
> Can somebody help me with this?
>
> Thanks!
>
> Greetings,
> K.
>