I have search long and hard, and cannot find a definitive answer.
I have 2 webapps running on a single instance of tomcat: /server
and /ROOT
I have configured Hibernate Search configured for one of my entities, ie Products
.
These entities are edited/added on /server
and searched for by front end users on the website /ROOT
during normal operations, everything works as it should, editing entities on the server will result in those changes reflecting when doing a search on the front end.
however, after an undetermined time, or sequence of events, the index no longer gets updated.
here is the configuration for /server
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="jpaDataSource" />
<property name="packagesToScan" value="com.foo" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="true" />
<property name="showSql" value="true" />
</bean>
</property>
<property name="jpaPropertyMap" ref="jpaPropertyMap" />
</bean>
<util:map id="jpaPropertyMap">
<entry key="hibernate.search.default.directory_provider" value="filesystem" />
<entry key="hibernate.search.default.indexBase" value="${lucene.index.folder}" />
</util:map>
and here is the config for /ROOT
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.foo" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="true" />
<property name="showSql" value="true" />
</bean>
</property>
<property name="jpaPropertyMap" ref="jpaPropertyMap" />
</bean>
<util:map id="jpaPropertyMap">
<entry key="hibernate.search.default.directory_provider" value="filesystem" />
<entry key="hibernate.search.default.indexBase" value="${lucene.index.folder}" />
</util:map>
Essentially identical.
and here is how my Entity is configured, via an AspectJ ITD
privileged aspect Product_Search {
declare @type: Product: @Indexed;
declare @method :public Long Product.getId() : @DocumentId;
declare @method :public String Product.getTitle() : @Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO);
declare @method :public String Product.getSubTitle() : @Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO);
declare @method :public String Product.getAlternativeTitle() : @Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO);
declare @method :public String Product.getIdentifier() : @Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO);
declare @method :public String Product.getPrimaryCreators() : @Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO);
declare @method :public String Product.getSecondaryCreators() : @Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO);
declare @method :public String Product.getSubjectArea() : @Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO);
declare @method :public String Product.getPublisher() : @Field(index=Index.YES, analyze=Analyze.NO, store=Store.NO);
declare @method :public String Product.getTags() : @Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO);
Upon further searching, I discovered the master/slave DirectoryProvider
/server
<util:map id="jpaPropertyMap">
<entry key="hibernate.search.default.directory_provider" value="filesystem-master" />
<entry key="hibernate.search.default.indexBase" value="${lucene.index.folder}/primary" />
<entry key="hibernate.search.default.sourceBase" value="${lucene.index.folder}/master" />
<entry key="hibernate.search.default.refresh" value="120" />
</util:map>
/ROOT
<util:map id="jpaPropertyMap">
<entry key="hibernate.search.default.directory_provider" value="filesystem-slave" />
<entry key="hibernate.search.default.sourceBase" value="${lucene.index.folder}/master" />
<entry key="hibernate.search.default.indexBase" value="${lucene.index.folder}/slave" />
<entry key="hibernate.search.default.refresh" value="300" />
</util:map>
This seemed to work, until earlier to day, when for some reason, my index "reset" itself, and only contained the items that were part of the last product import.
What I mean is, that my DB has 10000 items, but if I did a query = new MatchAllDocsQuery();
, I only got 15 (the size of the last import)
This is really driving me crazy.
At the moment, I am having to bring down the websites, delete the index, start the server, reindex using FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager());
fullTextEntityManager.createIndexer().startAndWait();
Let me know if you need any more info
Thanks