-->
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.  [ 5 posts ] 
Author Message
 Post subject: [HibernateSearch] Not indexed
PostPosted: Thu Jul 21, 2011 6:01 am 
Beginner
Beginner

Joined: Wed Jul 20, 2011 5:07 am
Posts: 23
i have problem :

i have got class:


Code:
@MappedSuperclass
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class AUser implements Serializable, Cloneable
{
   private static final long serialVersionUID = 1L;

   @Id
   @GeneratedValue(strategy=GenerationType.IDENTITY)
   @DocumentId
   private long id;   
   
   @Field
   private String title;   
   @Field
   private String description;
        //getters setters etc
}


Code:
@Indexed
public class TPerson extend AUser
{
     public static TPerson()
     {
        super();
     }
     public TAlbum(
      String title,
                String description
   )
        {
           super(title,description);
        }
//getters setters etc
}

@Indexed
public class Person extends AUser
{
   private static final long serialVersionUID = 1L;   
   
   @OneToMany
   @JoinColumns({
      @JoinColumn(name="personId", referencedColumnName="id")
   })
   @IndexedEmbedded
   private List<TPhoto> photos;
//getters setters etc
}

public class Photo implements Serializable, Cloneable
{
       private long id;
       private long personId;
       @Field
       private String title;
//getters setters etc
}


And as you see class TPerson have got the same field as AUser and when i insert, update TPerson in entityManager is automaticaly indexed (see in Luke ) and everything is ok.

but when i remove or update TPerson indexed are still in Indexed Strore ??
when i update new words are indexed but old word not deleted ??


But what i must do to automatic indexed class Person because i need to indexed class Person not TPerson??

And i have one more question when i update , delete or insert new Photo (new field title in Photo) that means automaticaly indexed this field ??

My property in persistence.xml
Code:
<properties>
        <!-- use a file system based index -->
        <property name="hibernate.search.default.directory_provider" value="org.hibernate.search.store.FSDirectoryProvider"/>
        <!-- directory where the indexes will be stored -->
        <property name="hibernate.search.default.indexBase" value="/usr/local/storage/pte/photoservice/searchindex"/>
        
        <property name="hibernate.ejb.event.post-insert" value="org.hibernate.search.event.FullTextIndexEventListener"/>
         <property name="hibernate.ejb.event.post-update" value="org.hibernate.search.event.FullTextIndexEventListener"/>
         <property name="hibernate.ejb.event.post-delete" value="org.hibernate.search.event.FullTextIndexEventListener"/>
         <property name="hibernate.search.worker.batch_size" value="2000" />   
         <property name="hibernate.search.default.refresh" value="9000" />     
    </properties>


Top
 Profile  
 
 Post subject: Re: [HibernateSearch] Not indexed
PostPosted: Thu Jul 21, 2011 6:28 am 
Beginner
Beginner

Joined: Mon Apr 11, 2011 7:56 am
Posts: 38
Quote:
but when i remove or update TPerson indexed are still in Indexed Strore ??
when i update new words are indexed but old word not deleted ??

In Luke, what do you see at 'Has deletions/Optimized? : X/X" ?
Deletions are not directly processed, see Chapter 7. Index Optimization.

Quote:
But what i must do to automatic indexed class Person because i need to indexed class Person not TPerson??

What is the problem exactly? Is Person currently not indexed if you add a new Person instance?


Top
 Profile  
 
 Post subject: Re: [HibernateSearch] Not indexed
PostPosted: Thu Jul 21, 2011 6:40 am 
Beginner
Beginner

Joined: Wed Jul 20, 2011 5:07 am
Posts: 23
OK thx

The problem is that in all project when i insert new User i use class TPerson not Person (Person and TPerson extend AUser where is @Field)
class Person is only for read not write /update /delete. So i thinking that when i update/delete/remove New TPerson so Person is automatic indexed
but its not working as i need. Its possible add this functionality ?

And if i change (update/delete/insert) title in Photo Person automatically indexed this field ??

I wrote test and Person is automatically indexed but i need indexed class Person when i insert/update/delete class TPerson

in luke i see Has deletion ? / Optimized ? Yes(2)/No

I add into persistence.xml
Code:
<property name="hibernate.search.default.optimizer.transaction_limit.max" value="100"/>
         <property name="hibernate.search.worker.batch_size" value="2000" />


And when i update TPerson i see

in luke i see Has deletion ? / Optimized ? Yes(2)/No

before i do this i clean /build /deploy project and restart Jboss


Last edited by lukasw44 on Thu Jul 21, 2011 7:01 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: [HibernateSearch] Not indexed
PostPosted: Thu Jul 21, 2011 6:59 am 
Beginner
Beginner

Joined: Mon Apr 11, 2011 7:56 am
Posts: 38
Updates to indexed entities are processed by deleting the relevant document(s) from the index, and recreating the document(s) with the updated data. The deleted documents are still in the index, but marked for deletion (and thus ignored during querying). For performance reasons, they are not deleted directly, but on optimization. You can manually optimize the index, or configure Hibernate Search to do that (see ch 7).

I currently don't see any link between Person and TPerson, only that they have the same super class. Maybe it's best to have a reference to TPerson from Person (one to one) and use embedded indexing.
I also notice that, in the snippet you posted, there is no @ContainedIn annotation at the Photo class, which is needed to let embedded indexing work correctly. See chapter 4.1.3 in the manual.
Edit: @ContainedIn should be in TPhoto, my bad.


Top
 Profile  
 
 Post subject: Re: [HibernateSearch] Not indexed
PostPosted: Thu Jul 21, 2011 8:26 am 
Beginner
Beginner

Joined: Wed Jul 20, 2011 5:07 am
Posts: 23
I have got solution when i delete update or insert TPerson so i update index in Album ?

i thing its so bad solution but its might work fine

Code:
@Override
   public long insertTPerson(TPerson person)
   {
      entityManager.persist(person);
      Query query = entityManager.createNamedQuery("Person.getPersonById");
      query.setParameter("id", person.getId());
      FullTextEntityManager ftem =  org.hibernate.search.jpa.Search.createFullTextEntityManager(entityManager);
      ftem.index(query.getSingleResult());      
      return album.getId();
      
      
   }


But what i need to do when delete or update TPerson ?
Code:
@Override
   public void deleteTPerson(long id)
      throws Exception
   {
      TPerson found = entityManager.find(TPerson.class, id);
      if (found == null)
      {
         throw new Exception ("TPerson with id: " + id+ " not found.");
      }else{
         Query query = entityManager.createNamedQuery("Person.getPersonWithId");
         query.setParameter("id", id);
         FullTextEntityManager ftem =  org.hibernate.search.jpa.Search.createFullTextEntityManager(entityManager);
              ??????
      }
      entityManager.remove(found);
   }


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