-->
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.  [ 4 posts ] 
Author Message
 Post subject: [Hibernate-Search] Index Update Problem
PostPosted: Thu Dec 06, 2007 9:11 am 
Newbie

Joined: Thu Dec 06, 2007 8:43 am
Posts: 2
Hello Hibernate-Users!

I've a question concerning a strange problem using hibernate search:

If we index our database manually or insert objects everything works fine and hibernate search is able to find all the objects. The problem encounters if we update objects: even the FullTextIndexEventListener is triggered, nothing seems to change inside the index. the object is found with the old search values (with the new values from the database loaded by hibernate core). If we search with the new values nothing is found. We also tried to optimize the index, with no sucess. The objects are not updated in the index.

Below the DEBUG output of the FullTextIndexEventListener

Code:
12:58:59,346 DEBUG LuceneWorker:89 - remove from Lucene index: class ch.xy.server.model.VCard#162698
12:58:59,362 DEBUG LuceneWorker:67 - add to Lucene index: class ch.xy.server.model.VCard#162698: Document<stored/uncompressed,indexed<_hibernate_class:ch.xy.server.model.VCard> stored/uncompressed,indexed<id:162698> indexed,tokenized<name:Hotel Cafe Fischer> indexed,tokenized<address:Weienburger Str. 31> indexed,tokenized<zip:63739> indexed,tokenized<city:Aschaffenburg> indexed,tokenized<country:Deutschland> indexed,tokenized<latitude:49.9781> indexed,tokenized<longitude:9.14461>>

We use the latest version of all hibernate libraries. No EntityManager is used.

Thanks a lot for your help!!! The problem drives me crazy... ;-)

Greetz

marmot57


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 06, 2007 11:44 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Can you post some minimal code that leads to the problem

_________________
Emmanuel


Top
 Profile  
 
 Post subject: More Info
PostPosted: Thu Dec 06, 2007 12:50 pm 
Newbie

Joined: Thu Dec 06, 2007 8:43 am
Posts: 2
Hi emmanuel!

Thanks for your assistance! In the meantime I was able to isolate the problem a bit more. It seems that the object structure causes the issue. Below the structure of my classes:

1. First I store location objects:
Code:
@Indexed
public class Location implements XMLConvertible {
    @DocumentId
    private Long locationId;
    @IndexedEmbedded
    private VCard card;
    ...


2. Associated with locations are vcards:

Code:
@Indexed
public class VCard {
    @DocumentId
    private Long id;
    @Field(index=Index.TOKENIZED)
    private String name;
    @Field(index= Index.TOKENIZED)
    private String firstName;
    @Field(index= Index.TOKENIZED)
    private String address;
    @Field
    private String zip;
    ...


Maybe I mis-configured something or I didn't completely understand how HS works but when I index Location objects manually (with fullTextSession.index(location)), HS insert the tokens flat:

Code:
Document<stored/uncompressed,indexed<_hibernate_class:ch.xy.server.model.Location> stored/uncompressed,indexed<locationId:80250> stored/uncompressed,indexed<card.id:162707> indexed,tokenized<card.name:Hotel Cafe Fischer> indexed,tokenized<card.address:Weienburger Str. 31> indexed,tokenized<card.zip:63739> indexed,tokenized<card.city:Aschaffenburg> indexed,tokenized<card.country:Deutschland> indexed,tokenized<card.latitude:49.9781> indexed,tokenized<card.longitude:9.14461>>


But when I insert a location via hibernate, HS creates two documents: one Location document (same code as above) and a VCard document like this:

Code:
Document<stored/uncompressed,indexed<_hibernate_class:ch.xy.server.model.VCard> stored/uncompressed,indexed<id:162707> indexed,tokenized<name:Hotel Cafe Fischer> indexed,tokenized<address:Weienburger Str. 31> indexed,tokenized<zip:63739> indexed,tokenized<city:Aschaffenburg> indexed,tokenized<country:Deutschland> indexed,tokenized<latitude:49.9781> indexed,tokenized<longitude:9.14461>>


The problem now encounters when i update a location: HS just updates the VCard document. Because I search in the location index for card.name for example lucene just finds the old value (inserted via initial update).

So my question is now: How can I handle a structure like this (and why HS inserts the information twice)? How can I insert the VCards with fullTextSession.index (and the link to the locations) and how can i search the vcards in the location, because there a also vcards associated with people?

Thanks a lot for your help!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 06, 2007 5:47 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
So if I understand correctly, when you say I update Location, you are really updating the VCard associated to Location but no attribute in Location.

To make Location be updated, you need to add a @ContainedIn in annotation in VCard on the property that reference back to Location (you need a bidirectional relationship). The reference doc is a bit unclear about that, but some of the examples might help you.

_________________
Emmanuel


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