Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Indexing subclass fields by IndexEmbedded
PostPosted: Sat Mar 19, 2011 3:16 am 
Newbie

Joined: Thu Mar 17, 2011 4:33 am
Posts: 2
Im am using NHibernate.Search and Lucene.Net (Maybe I will be banned from the forum for using .NET:) ). I will ask if anyone have experienced similar problems. This is the situation regarding the following three classes.

Code:
[Indexed]
    public class File
    {
        [Field]
        public virtual string FileId { get; private set; }

        [ContainedIn]
        public virtual List<Record> Records { get; private set; }
    }

    [Indexed]
    public class CaseFile : File
    {
        [Field]
        public virtual int CaseYear { get; set; }
        [Field]
        public virtual int CaseSequenceNumber { get; set; }
    }

    [Indexed]
    public class Record
    {
        [IndexedEmbedded]
        public virtual File ParentFile { get; set; }
    }


The problem is when I try to index the record class. The goal is to get all fields of both the File class and the subclass CaseFile contained in the Record index. But when i index the Record class I only get fields of the File superclass in my Record index. The fields of the CaseFile subclass are missing in the Record index.

I have also tried the [IndexedEmbedded(TargetElement = typeof(CaseFile))] on the ParentFile propery in the Record class, but this leads to totally empty indexes, or no indexing at all.

If I index the File class, the expected subclass properties are indexed as expected in the File index.

Have anyone in the Hibernate community experienced similar problems with Hibernate search?


Top
 Profile  
 
 Post subject: Re: Indexing subclass fields by IndexEmbedded
PostPosted: Sun Mar 20, 2011 9:14 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2296
Location: Third rock from the Sun
Hi,
I don't know much about the .Net version, hope it goes well with him but it's not maintained by us.
Still I think you have luck, as a similar limitation applies to the Java version so I might be able to give some hints:

for each type a DocumentBuilder is created at startup, a DocumentBuilder is the object used to transform a specific entity into it's Lucene Document counterpart.

This DocumentBuilder is created at startup and is linked to the Record type, but only knows about the static types you declared, so it doesn't know about the CaseYear and CaseSequenceNumber in the scope of creating a Lucene document for a Record.

you'll have to change the mapping to work around this, or use a custom ClassBridge for Record. A classbridge is able to add all fields it wants dynamically.

It's quite a limitation, please comment here as well as you have thoughts on it: HSEARCH-438

Even if we fix it in the Java version, I have no clue how long it will take, and if anybody will do at all, to bring it into the .Net worlds.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Indexing subclass fields by IndexEmbedded
PostPosted: Sun Mar 20, 2011 1:26 pm 
Newbie

Joined: Thu Mar 17, 2011 4:33 am
Posts: 2
Thank you for the reply. I think i will try the classbridge for the time beeing. But if was to experiment a little with the source code the place to begin would be in the DocumentBuilder class? If you have any more spesific tips of what changes are needed in the code (in the Java version of course :) ) i would be very grateful!

Anyway I love Nhibernate/Hibernate search! Fantastic tool!


Top
 Profile  
 
 Post subject: Re: Indexing subclass fields by IndexEmbedded
PostPosted: Sun Mar 20, 2011 5:45 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2296
Location: Third rock from the Sun
thank you,
let's continue the discussion on HSEARCH-438

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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.