-->
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.  [ 6 posts ] 
Author Message
 Post subject: Search Without JPA Annotations creates corrupt index?
PostPosted: Thu Jul 26, 2007 1:34 pm 
Newbie

Joined: Tue Jul 18, 2006 1:17 pm
Posts: 8
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2.2
hibernate-search version: 3.0b3 [b]
[hibernate-annotations and common annotations: 3.0
.

I'm working on executing the indexing code from the hib search documentation, and though and index is being generated, it contains nothing, and is actually corrupt according to lucene (using Luke to read it).

The only difference I can see between what I'm doing and the examples is the fact that we're still using the xml mapping documents rather than the JPA or hibernate annotations...

I've a parent class A that contains the id and a subclass I'm trying to index
Code:
public class A
{
..
   public String getId()

}

@Indexed
public class B extends A
{
  //one @Field is annotated.
}


I'm running a query "SELECT aObj FROM A aObj" and indexing it through the full text session as in the docs.

When the code is done, the TX is committed, I have 2 small segment files in the index directory, and it reads as a corrupted index.

I'm going nuts here so any help is appreciated :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 26, 2007 1:50 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
A few folks are running Hibernate Search with XML mappings, so no this is not the root cause.

Check the lucene version, luke is bound to a given version, so sue the same (try 2.2).
If it does not help show more of your code and config.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: More code and config
PostPosted: Thu Jul 26, 2007 4:14 pm 
Newbie

Joined: Tue Jul 18, 2006 1:17 pm
Posts: 8
I checked the lucene version - the version of luke I have is bound to 2.2 which is what I have in my app's classpath, so that's out.

Here's the code doing the indexing:

Code:
                String query = "SELECT f FROM FoilImpl f";
                s = vslHibernateSessionFactory.openSession();
//                Query q = s.createQuery(query);
//                List<Foil> foils = (List<Foil>)q.list();
                FullTextSession fullTextSession = org.hibernate.search.Search.createFullTextSession(s);
                Criteria c = fullTextSession.createCriteria(FoilImpl.class);
                Transaction tx = fullTextSession.beginTransaction();
                for (Foil foil : (List<Foil>)c.list()) {
                    fullTextSession.index(foil);
                }
                tx.commit();


Here's the FoilImpl class: (slightly abbreviated)

Code:

@Indexed()
public class FoilImpl extends VSLObjectImpl implements Foil {

   
    @DocumentId
    public String getId() {
        return this.id;
    }

      @Field(index=Index.TOKENIZED)
    public String getIdentifier(){
    return identifier;
    }
}



The mapping for foil:

Code:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
       
<hibernate-mapping>
    <class name="org.company.vsl.beans.FoilImpl" table="FOIL" proxy="org.company.vsl.beans.Foil">
        <id name="id" column="FOIL_ID">
            <generator class="uuid"/>
        </id>
        <property name="key" column="KEY_FL" />
        <property name="createdBy" column="CREATED_BY_NM" />
        <property name="createdOn" column="CREATED_ON_DT" type="timestamp" />
        <property name="updatedBy" column="UPDATED_BY_NM" />
        <property name="updatedOn" column="UPDATED_ON_DT" type="timestamp" />
        <many-to-one name="interaction" lazy="proxy" class="org.company.vsl.beans.InteractionImpl" column="INTERACTION_ID" not-null="true" insert="false" update="false" not-found="ignore"/>
    </class>
</hibernate-mapping>


and in the session factory configuration I'm setting:

Code:

<prop key="hibernate.lucene.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>
                <prop key="hibernate.lucene.default.indexBase">c:/vslIndexes</prop>
                <prop key="hibernate.search.default.indexBase">vsl</prop>


as well as the appropriate listeners. I get 2 files in c:/vslIndexes - 4 or 5 bytes each... it's as thought the commit isn't quite flushing the entire index to the FS.

If there's something I forgot to include let me know.

Thanks for the assist.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 27, 2007 12:44 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Several questions:
identifier is indexed but is not mapped in hbm xml, is that really what you want? It will be null all the time, the way you load data.

<prop ...> is not a valid element of hibernate.cfg.xml. What are you using? can you show the excat but all the config?

Do you read the index right away?
What if you try to do a query using hibernate search, do you get the expected results, or is there a corrupted index exception as well. Luke might have some issues as well after all :)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 27, 2007 2:14 pm 
Newbie

Joined: Tue Jul 18, 2006 1:17 pm
Posts: 8
I actually trimmed the mapping file as well as the java source file - the identifier is actually mapped in the full file. My bad for a bad trimming.

<prop> is what's being used as this is a spring configured hibernate session factory.

I'm actually using the same config (save the names of a few classes) that I used from a different project wherein I was using hib-search b1. All works well there.

I don't read the index right away - I'm waiting for the code to fully index all of the entities, and then am attempting to mount the index.

The same version of lucene indexing the same entities manually (using the lucene apis directly) creates an index of several hundred k, and luke mounts it correctly.

I did try to read the index with hibernate search, and there is the same corrupted index exception.

Is there something I'm missing config wise related to not configuring a worker or some such, or will hib search automagically use a default worker if none is configured?

Also - the 2 little segment files being produced are produced by the above code as I can delete them, re-run my little batch indexer, and they show up again.

Thanks,
B


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 27, 2007 3:43 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you will need to show more, simplify the case and post all the artifacts, I don't understand why it's failing.

_________________
Emmanuel


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