-->
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.  [ 9 posts ] 
Author Message
 Post subject: Hibernate search includes only the newly created recors
PostPosted: Mon Apr 05, 2010 10:14 am 
Newbie

Joined: Mon Mar 29, 2010 9:15 am
Posts: 14
Hi All,

I am using hibernate search. I am new to this. When I try to invoke records using this, only the newly created|updated records only getting fetched.

Do I need to add any listeners to hibernate.cfg.xml and persistence.xml?

As if now my hibernate.cfg.xml and persistence.xml looks like this::

persistence.xml

<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd"
version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="apptivodb2">
<jta-data-source>java:xaApptivodb2</jta-data-source>
<properties>
<property name="hibernate.ejb.cfgfile"
value="/META-INF/hibernate.cfg.xml" />
<property name="jboss.entity.manager.jndi.name"
value="persistence-units/apptivodb2" />
<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.default.indexBase" value="/home/skuppusamy/Hibernate/Indexes"/>

</properties>
</persistence-unit>
</persistence>

hibernate.cfg.xml:

<?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE hibernate-configuration PUBLIC

"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">



<hibernate-configuration>



<session-factory>



<!-- JDBC connection pool (use the built-in) -->

<property name="connection.pool_size">1</property>



<!-- SQL dialect -->

<property name="dialect">

org.hibernate.dialect.PostgreSQLDialect

</property>



<!-- Enable Hibernate's automatic session context management -->

<property name="current_session_context_class">jta</property>





<!-- Enable the second-level cache -->

<!-- Provider is JBoss Cache -->

<!--<property name="cache.provider_class">org.jboss.hibernate.jbc.cacheprovider.JndiBoundTreeCacheProvider</property>-->



<property name="hibernate.cache.jndi">

JndiBoundTreeCacheInstance

</property>



<!-- Transaction factory that supports JTA -->

<property name="transaction.factory_class">

org.hibernate.transaction.JTATransactionFactory

</property>



<!-- enable caching of entities and collections -->

<property name="cache.use_second_level_cache">true</property>



<!-- enable caching of query results -->

<property name="cache.use_query_cache">true</property>



<property name="cache.region.jbc2.query.localonly">

true

</property>



<!-- JBoss Cache configuration file name -->

<property

name="cache.provider_configuration_file_resource_path">

jboss-cache.xml

</property>



<!-- To use JBoss Cache 2 as your Second Level Cache implementation -->

<property name="cache.region.factory_class">

org.hibernate.cache.jbc2.MultiplexedJBossCacheRegionFactory

</property>



<!-- Use query cache too -->

<property name="cache.use_query_cache">true</property>



<!-- JBoss Transactions Manager lookup class -->

<property name="transaction.manager_lookup_class">

org.hibernate.transaction.TransactionManagerLookup

</property>



<!-- Echo all executed SQL to stdout -->

<property name="show_sql">true</property>

<event type="post-update">
<listener
class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>
<event type="post-insert">
<listener
class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>
<event type="post-delete">
<listener
class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>


</session-factory>



</hibernate-configuration>


Please can anyone help me...?

I am getting the following exception when I added the following properties to hibernate.cfg.xml:

<event type="post-collection-recreate">
<listener
class="org.hibernate.search.event.FullTextIndexCollectionEventListener" />
</event>
<event type="post-collection-remove">
<listener
class="org.hibernate.search.event.FullTextIndexCollectionEventListener" />
</event>
<event type="post-collection-update">
<listener
class="org.hibernate.search.event.FullTextIndexCollectionEventListener"/>
</event>

And the exception is:::
Error parsing XML: /META-INF/hibernate.cfg.xml(80) Attribute "type" with value "post-collection-recreate" must have a value from the list "auto-flush merge create create-onflush delete dirty-check evict flush flush-entity load load-collection lock refresh replicate save-update save update pre-load pre-update pre-insert pre-delete post-load post-update post-insert post-delete post-commit-update post-commit-insert post-commit-delete ".

Thanks in Advance,
Sorna.K


Top
 Profile  
 
 Post subject: Re: Hibernate search includes only the newly created recors
PostPosted: Tue Apr 06, 2010 5:31 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hello,
I think you're using a very old hibernate.
All "post-collection-*" eventlisteners where added in hibernate core 3.2.6, not supported before.

And if you update to a newer hibernate core and annotations you don't need to register the listeners, that's automatic.

Hint: always post the versions of the libraries

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


Top
 Profile  
 
 Post subject: Re: Hibernate search includes only the newly created recors
PostPosted: Tue Apr 06, 2010 5:52 am 
Newbie

Joined: Mon Mar 29, 2010 9:15 am
Posts: 14
Hi,

Thanks for your valuable response.

Sorry... Here follows my jar files listing:

hibernate-core-3.3.1.GA.jar
hibernate3.jar
hibernate-search-3.1.1.GA.jar

lucene2.9.1.jar


and yes I found event listeners are defined in hibernate-core-3.3.1.jar itself.

Actually my problem is....

Search does not include already created records.

After index file created If I create record, then that only included in search. What I want is all my records in DB must get included for searching.

What I need to do for this..

Thanks in Advance,
Sorna.K


Top
 Profile  
 
 Post subject: Re: Hibernate search includes only the newly created recors
PostPosted: Tue Apr 06, 2010 6:00 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
After index file created If I create record, then that only included in search. What I want is all my records in DB must get included for searching.

The indexes should contain matching Lucene Documents for each of your indexed database records; this means that if you have an existing index you'll have to reindex.

With Hibernate Search 3.1.x you have to read: http://docs.jboss.org/hibernate/stable/search/reference/en/html/search-batchindex.html

in Search 3.2 there's a new API to make this simpler and faster.

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


Top
 Profile  
 
 Post subject: Re: Hibernate search includes only the newly created recors
PostPosted: Tue Apr 06, 2010 6:21 am 
Newbie

Joined: Mon Mar 29, 2010 9:15 am
Posts: 14
Thanks much Sanne!!!


I will reply you after finishing my task successfully. It was really helpful.

Thanks,
Sorna.K


Top
 Profile  
 
 Post subject: Re: Hibernate search includes only the newly created recors
PostPosted: Thu Apr 08, 2010 5:11 am 
Newbie

Joined: Mon Mar 29, 2010 9:15 am
Posts: 14
Hi Sanne,


Thanks much for your valuable help. I am done with search successfully.

Thanks and regards,
Sorna.K


Top
 Profile  
 
 Post subject: Re: Hibernate search includes only the newly created recors
PostPosted: Thu Apr 08, 2010 5:13 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
cool!
have fun with it
Regards

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


Top
 Profile  
 
 Post subject: Re: Hibernate search includes only the newly created recors
PostPosted: Wed Apr 14, 2010 6:15 am 
Newbie

Joined: Mon Mar 29, 2010 9:15 am
Posts: 14
HI Sanne,

I am in need of your help... could u please extend your hand...

I my search...
If an Employee Name is Sorna Sundari(Say)
If I search with 'sor*' or 'sun*' it fetches result... But when I search with 'dar*' it does not fetch any :(.

Here is my code snippet:
@Field(index=Index.TOKENIZED ,name="employeefirstname_tokenized")
@Column(name = "FIRST_NAME")
private String firstName;
@Field(index=Index.TOKENIZED ,name="employeelastname_tokenized")
@Column(name = "LAST_NAME", nullable = false)
private String lastName;

In EJB:

String[] employeeFields={"employeefirstname_tokenized","employeelastname_tokenized","employeeEmailid_tokenized"};
FullTextEntityManager ftem = org.hibernate.search.jpa.Search.getFullTextEntityManager(em); QueryParser parser = new MultiFieldQueryParser(employeeFields,new StandardAnalyzer());
query = parser.parse(searchByName);
parser.setAllowLeadingWildcard(true);
FullTextQuery hibQuery = ftem.createFullTextQuery(query, AppHrEmployee.class); employeeSearchResults = hibQuery.getResultList();

All my fiedls are tokenized. What I need to do in this case..

Please Help me...

Thanks in Advance,
Sorna.K


Top
 Profile  
 
 Post subject: Re: Hibernate search includes only the newly created recors
PostPosted: Wed Apr 14, 2010 12:26 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi sorna,
please open a new topic when changing subject.

Quote:
If an Employee Name is Sorna Sundari(Say)
If I search with 'sor*' or 'sun*' it fetches result... But when I search with 'dar*' it does not fetch any :(.

that's by design ;-)

Assuming you're using the StandardAnalyzer also for indexing (as you did for queryparsing):

"Sundary" will be matched by the queries "sundary" and "sundar*" and "s*" and "su*" and "sun*" and "sund*" ...
but "dar*" will match "dar" and "dary" but not any word starting in a different way.
Use "*dar*" to match both sides of the expression.

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


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