-->
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.  [ 2 posts ] 
Author Message
 Post subject: inserting a single class into multiple indexes
PostPosted: Wed Aug 27, 2008 12:05 pm 
Newbie

Joined: Mon Aug 18, 2008 12:19 pm
Posts: 1
I've just recently started using Hibernate Search, and I'm trying to figure out how I might go about indexing a single class into multiple indexes with slightly different information. Each index has a concept of "uniqueness" (@DocumentId), but the field needs to be different for each index. My initial reaction is that a single class can't support this. Is that correct?

So I have a single entity Foo that needs to be indexed in both index A and index B. Foo has multiple fields, including version and revision. Index A sees Foo as unique based on its version number. Index B sees Foo as unique based on its revision number.

I'm interested in any recommendations as to how I might go about this. I was thinking of some kind of inheritance, but that hasn't worked for me yet. I'm using a MySQL database, if it makes any difference.

Thanks,
Clay


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2008 9:21 am 
Hibernate Team
Hibernate Team

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

indexing the same class into two different indexes is not possible. However, you might not have to. If your usecase is to index certain fields of entity in multiple ways, just use @Fields. This annotation allows you to index the same field multiple times using for example different Analyzers. Or just write your own Field- or ClassBRridge. Doing so will also allow you to control exactly which fields are added to the Lucene document.

At query time you can then just decide yourself which fields to query.

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.