We want to enable fulltext search on a Hibernate database for only some objectes of a specific entity. Is there a way to prevent hibernate search from indexing some instances of this entity? We do not want to filter the search results, we just want some instances to not be indexed at all.
An example: We have a database with employees, both active and retired. We don’t need to be able to search retired employees. We’re a very old IT company, founded in 1695, therefor we have about 2 million retired employees that we are very fond of, but don’t want to index, only the 10 active ones. Is there a way we can tell Hibernate Search to only index employees where retired = false?
Regards,
Jochen
I don’t think that you should work with the IndexReader directly in your event listener. You should instead extend (or write a new version) of the existing FullTextIndexEventListener and inspect your entity in the callback method and depending on the retired field call or not call processWork.
If you want to use Hibernate Search 4 (together with Hibernate Core 4) you will also need a custom HibernateSearchIntegrator.
This solution will work, but should be considered an interim solution until HSEARCH-471 is implemented.