-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Fields in Documents
PostPosted: Sun Sep 13, 2009 3:38 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Hi

As I understand when you annotate your entities you effectively create fields based on the object graph, for example

Code:
a.setOfObjects.reference
a.setOfObjects.object.reference


You can use @IndexEmbedded with prefix to control the field that gets created. However is it possible to basically put all contents from all of the object graph into one field? I know this may sound strange but I'm looking at avoiding multiple fields to query inorder to get results. I was reading LuceneFAQ and it mentioned the option of putting all contents into one contents field.



Cheers
Amin


Top
 Profile  
 
 Post subject: Re: Fields in Documents
PostPosted: Sun Sep 13, 2009 5:54 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

I guess you could set the prefix for @IndexEmbedded to the empty string. Besides you would have to use the name attribute of the field annotation to use the same field name for all properties.

Personally, I would not recommend this approach, since it make it harder to evolve the search queries. Using different field name for the properties gives you much more query possibilities.

If you still go ahead with this approach feel free to report your results here.

--Hardy


Top
 Profile  
 
 Post subject: Re: Fields in Documents
PostPosted: Sun Sep 13, 2009 9:38 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Hi

Thanks for your reply. I presume when you said
Quote:
I guess you could set the prefix for @IndexEmbedded to the empty string.

You mean do the following:
Code:
@IndexEmbedded(prefix="")


I will give this a try. I understand what you mean about not a recommended approach. I will probably look at this as an option. I noticed that our domain model has a deep object graph and the data i need creates fields like this

Code:
topObject.setOfObjects.object.reference
topObject.setOfAnotherObjects.object.object.reference
...and so on..depending on the data i need to index


So the query I need to generate looks like this
Code:
topObject.setOfObjects.object.reference:test topObject.setOfAnotherObjects.object.object.reference:test ...and so on


I tried to group fields together but the @IndexEmbedded worked to a certain point but when there was other objects I was getting different field names. For example

Code:

@Indexed
Class A

@IndexEmbedded(prefix="risk.")
Set<B> projects


Class B
  @ContainedIn
  A a
 
  @Field(name="data" ...)
  String reference

@IndexEmbedded(prefix="risk."
  Set<C> c


C
  @ContainedIn
  B

  @Field(name="data" ...)
  String reference
[code]

So indexing the above looks like this:

[code]
risk.data
risk.risk.data
[/code]

where as I would like to do
[code]
risk.data

And get all contents (e.g. references from all of the object graph into one field.

I will try what you mentioned.

Cheers


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.