jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mato <djmatoli...@gmail.com>
Subject Re: Searching with OCM
Date Wed, 15 Dec 2010 15:07:01 GMT
Ok, I'll answer myself, maybe it'll help somebody struggling with these
basic things.
Searching through all attributes, even if they are references to object, can
be done by specifiing @Bean annotation with
converter=InlineBeanConverterImpl.class option. Then searching on parent
object will match.
In my example:
public class Person {
@Bean(converter=InlineBeanConverterImpl.class) private Address address;
..
}

Or the other way around, searching in object that is included in some parent
object, you need to add reference to the parent object to the included
object with opiton converter=ParentBeanConverterImpl.class) to be able to
retrieve the parent object.
public class Address {
@Bean(converter=ParentBeanConverterImpl.class) private Person person;
...
}

This way, searchable files can be included to some object. You just need to
add an attribute with name jcr:content that is of type nt:resource.
Searching on parent object will also search in file.

public class Person {
@Bean(jcrName = "jcr:content", converter=InlineBeanConverterImpl.class)
private Resource file;
..
}

and finally Resource class is like you can find here:
http://svn.apache.org/repos/asf/jackrabbit/commons/ocm/trunk/src/test/java/org/apache/jackrabbit/ocm/testmodel/Resource.java

Martin

On Sat, Dec 11, 2010 at 12:32 AM, Mato <djmatoliski@gmail.com> wrote:

> Hi everybody,
>
> my apologies in advance if my questions are a bit dumb, but I've spent
> several days now getting to know jackrabbit and ocm and I'm getting little
> frustrated.
>
> Ok, my main question is, Is there a way how to search all fields of a Node,
> including beans?
> I've got a class person, which has several attributes, one of which is bean
> class address with mapping 1:1.
>
> @Node(jcrMixinTypes="mix:referenceable")
> public class Person {
> @Field(path=true) private String path;
> @Field(id=true) private int id;
> @Field private String firstName;
> @Field private String lastName;
> @Bean private Address address;
> //getters and setters
> }
>
> @Node
> public class Address {
> @Field private String street;
> @Field private String streetNumber;
> //getters and setters
> }
>
> I'd like to perform a search on all attributes of person including address
> and retrieve matching person. How can this be done?
>
> My another concern is this: I'd like to store a pdf file associated with a
> person, so a full text searching would be performed also in pdf content. I
> was able to manage this without ocm quite easily, but with ocm I have had no
> luck so far. I saw all the File, Resource classes but no result.
>
> If this is somehow trivial I'd be happy if you pointed me in the right
> direction. Any help will be appreciated.
> Thanks
>
> Martin
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message