-->
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: Updating a collection does not reindex
PostPosted: Wed Nov 30, 2011 1:59 pm 
Newbie

Joined: Sat Feb 12, 2011 3:49 pm
Posts: 13
When I add a new element to a Set, the Lucene index is not updated. This is the code I use:

Code:
session = HibernateUtil.getSessionFactory().openSession();
tx = session.beginTransaction();
Node node = (Node) session.load(Node.class, uuid);

if (!node.getKeywords().contains(keyword)) {
   node.getKeywords().add(keyword);
}

session.update(node);
HibernateUtil.commit(tx);


The Node definition is:

Code:
@Entity
@Indexed
@Table(name="NODE")
public class Node {
   @ElementCollection
   @Column(name="KEYWORD")
   @CollectionTable(name="NODE_KEYWORD", joinColumns = { @JoinColumn( name = "NKW_UUID" ) })
   @Field(index=Index.UN_TOKENIZED, store=Store.YES)
   @FieldBridge(impl=SetFieldBridge.class)
   protected Set<String> keywords = new HashSet<String>();
}


According with these JIRA entries, seems to be solved but not for me:

- https://hibernate.onjira.com/browse/HSEARCH-56
- https://hibernate.onjira.com/browse/HHH-2616

Note: Used hibernate-core 3.6.8.Final and hibernate-search 3.4.1.Final


Top
 Profile  
 
 Post subject: Re: Updating a collection does not reindex
PostPosted: Wed Nov 30, 2011 2:27 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi, I'll need some more details or possibly a unit test to run and inspect.
You can easily create a new unit test by taking inspiration from other similar tests in the source code.

If you can't, please at least post the code of your SetFieldBridge implementation.

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


Top
 Profile  
 
 Post subject: Re: Updating a collection does not reindex
PostPosted: Wed Nov 30, 2011 2:41 pm 
Newbie

Joined: Sat Feb 12, 2011 3:49 pm
Posts: 13
This is the source of SetFieldBridge:

Code:
public class SetFieldBridge implements FieldBridge {
   @Override
   public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
      if (value instanceof Set<?>) {
         @SuppressWarnings("unchecked")
         Set<String> set = (Set<String>) value;
         
         for (String elto : set) {
            Field field = new Field(name, elto, luceneOptions.getStore(), luceneOptions.getIndex(),
                  luceneOptions.getTermVector());
            field.setBoost(luceneOptions.getBoost());
            document.add(field);
         }
      } else {
         throw new IllegalArgumentException("Support only Set<String>");
      }
   }
}


I will try to make an unit test but I can't promise anything.


Top
 Profile  
 
 Post subject: Re: Updating a collection does not reindex
PostPosted: Wed Dec 07, 2011 3:29 pm 
Newbie

Joined: Sat Feb 12, 2011 3:49 pm
Posts: 13
I have downloaded the Hibernate Search source code, but I can't find a test case which check this feature. Can anybody tell me if there is any already created testcase and where can I find it?


Top
 Profile  
 
 Post subject: Re: Updating a collection does not reindex
PostPosted: Mon Dec 12, 2011 8:22 am 
Newbie

Joined: Sat Feb 12, 2011 3:49 pm
Posts: 13
I have created the test. Should I create a JIRA ticket or perhaps you want to review it before it?

BTW I can't upload files in this forum.


Top
 Profile  
 
 Post subject: Re: Updating a collection does not reindex
PostPosted: Mon Dec 12, 2011 8:29 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Quote:
I have created the test. Should I create a JIRA ticket or perhaps you want to review it before it?

You can create a Jira issue and attach the code to the issue or you for the hibernate search code on GitHub and push your testcase to your fork.
If you post then a link to the test we can have a look at it before creating a Jira.

Quote:
BTW I can't upload files in this forum.

Correct, you cannot.


Top
 Profile  
 
 Post subject: Re: Updating a collection does not reindex
PostPosted: Mon Dec 12, 2011 9:06 am 
Newbie

Joined: Sat Feb 12, 2011 3:49 pm
Posts: 13
New JIRA bug created https://hibernate.onjira.com/browse/HSEARCH-1004 and attached the test case.

Thanks.


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.