-->
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.  [ 7 posts ] 
Author Message
 Post subject: Possible to index an object that isn't in the database?
PostPosted: Thu Dec 20, 2007 2:45 pm 
Newbie

Joined: Thu Dec 20, 2007 1:49 pm
Posts: 9
I've got indexing working for all objects that are already in the database. My issue is that I have an object that gets built out of a few different entities (they're already being indexed) and I need it indexed without storing it in the database.

Is this possible with Hibernate search?

Edit: Is it possible to index to different documents within the same entity?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 21, 2007 6:56 pm 
Newbie

Joined: Thu Dec 20, 2007 1:49 pm
Posts: 9
I ended up creating a classbridge on existing (but somewhat unrelated) entities to get this running.

My implementation feels like a complete hack and I'm not really happy with it, but I can't figure out another way around this problem...

The issue I've run into now is creating two documents from the same entity in the same index. I've marked a transient field as the documentId, but this seems to do nothing. The documentId is still getting pulled from the field marked as @Id, not the one from @DocumentId.

Am I doing something wrong here? I thought the documentId was the key for the indexed document...


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 22, 2007 5:27 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you will have to give some more information here.
But generally speaking, if you want to query an entity by some values non present in the database, a class level bridge is the way to go, you inject the related data in the document.

I did not really understand your comment about 2 documents per entity

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 24, 2007 3:58 pm 
Newbie

Joined: Thu Dec 20, 2007 1:49 pm
Posts: 9
emmanuel wrote:
you will have to give some more information here.
But generally speaking, if you want to query an entity by some values non present in the database, a class level bridge is the way to go, you inject the related data in the document.

I did not really understand your comment about 2 documents per entity


Without going too much into the business rules, I need to generate two documents from one entity (i.e. the entity will result in two separate index documents). The issue that I'm running into is that Hibernate Search will only call the class bridge once per entity, so it will only ever create one document. Here's some code:

Code:
      
for (Person person : people)
{
   RelationshipName rn = getRelationshipName(person);
   if(rn != null)
   {
      // This should call the class bridge
      fullTextEntityManager.index(rn);
   }

   Person otherPerson = getOtherPerson(person);
   rn = getRelationshipName(otherPerson);
   if(rn != null)
   {
      // this should call the class bridge again
      fullTextEntityManager.index(rn);
   }
}


What I would expect is that it indexes the entity twice. In reality, it only calls the class bridge once per iteration.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 26, 2007 6:19 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
That would lead to a lot of object duplication int he result list. One document per entity seem to be the right approach. What is your need for several documents per entity.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 26, 2007 5:28 pm 
Newbie

Joined: Thu Dec 20, 2007 1:49 pm
Posts: 9
emmanuel wrote:
That would lead to a lot of object duplication int he result list. One document per entity seem to be the right approach. What is your need for several documents per entity.


Basically, it all stems from the fact that what needs to be indexed is not a hibernate entity. The entity is only semi-related, so I need to pull a lot of references in the class bridge.

The entity contains multiple Person objects, and allows for different data to be returned based on who's looking at it.

I ended up writing a lucene indexer to build my index files for this specific problem. I can't believe I'm the first person to want this, though.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 03, 2008 3:14 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Well if you want to index data not related to entities, and specifically don't want to retrieve entities when based on matching data (in the generic sense of it) is found, then Hibernate Search is not what you are looking for.

_________________
Emmanuel


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