I noticed
http://in.relation.to/Bloggers/HibernateSearch34Alpha1FacetingQueryEngineRefactoringMorePerformanceTricks#H-UpdateIndexOnlyWhenAnIndexedPropertyChanges, this will be very useful.
For the selective indexing, we have couple of use cases.
Scenario: Say A is an indexable entity containing another entity B. In its life cycle, A gets cloned (say A') keeping the same link to B. Such A' may get associated to another entity C.
1. We dont want to index A' at the time of creation. We only want to index A' via C, whenever C gets created. Right now, our process of creating A' is very expensive because of unwanted indexing.
2. We would like to skip A' indexing during mass indexing as well (right now we do that old way of mass index using scollable result set)
Proposal: What if there is a way for application to have a say. Would it make sense to inject a qualifier per Entity and allow it to decide weather or not index need to be recreated. For each entity instance Hibernate search can then ask this qualifier to go ahead index or not.
Code:
@Entity
@Indexed
@IndexingQualifier{impl= EntityAIndexerQualifierImpl.class}
public class EntityA extends CustomizableEntity implements java.io.Serializable {
.
.
.
}
public class EntityAIndexerQualifierImpl extends IndexingQualifier{
@override
public Boolean indexNeeded(Object entity, Object[] changes){
}
}