| Sanne Grinovero I've been trying to add a command-line tool to export the mappings, similar to (but more limited than) what's provided by org.hibernate.tool.hbm2ddl.SchemaExport. Unfortunately, it seems very complex (if not impossible) to make Hibernate Search generate its internal Metadata without having it start its index managers. Thus we need to have an Elasticsearch instance available even if we simply want to export mappings to local files and be done with it... So it means I have two solutions:
- either I dig into Search to separate metadata building from index management, and then build a command-line tool.
- or I implement the mappings export feature as part of the index manager starting process. This seems really weird to me, but at least it would be easy to use for users...
Another issue is that, since the Elasticsearch module does not depend on Hibernate ORM, I cannot rely on ORM to build the Hibernate Search configuration (org.hibernate.search.cfg.impl.SearchConfigurationFromHibernateCore) and in particular to detect the indexed entities. Thus if we provide a command-line tool, one of the matters that will have to be addressed will be indexed entities auto-detection (we cannot decently ask users to list all their entities explicitly...). I'd like to speak with you before going any further, so I'll wait till you return from PTO before doing anything. The VALIDATE strategy is already working, by the way, so this export and documentation are all that's left for this ticket. Details: the configuration reading and metadata building seems to be bootstrapped from org.hibernate.search.spi.SearchIntegratorBuilder.buildNewSearchFactory(), and the same method also:
- creates the index managers through org.hibernate.search.spi.SearchIntegratorBuilder.initDocumentBuilders(SearchConfiguration, BuildContext, SearchMapping)) which calls org.hibernate.search.indexes.impl.IndexManagerHolder.buildEntityIndexBinding(XClass, Class, SearchConfiguration, WorkerBuildContext) which calls org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManagers(String, Properties[], Similarity, Class<?>, WorkerBuildContext)
- starts the index managers through a call to org.hibernate.search.engine.impl.MutableSearchFactoryState.setActiveSearchIntegrator(ExtendedSearchIntegratorWithShareableState) which calls org.hibernate.search.indexes.impl.IndexManagerHolder.setActiveSearchIntegrator(ExtendedSearchIntegratorWithShareableState) which calls org.hibernate.search.indexes.spi.IndexManager.setSearchFactory(ExtendedSearchIntegrator), which in the Elasticsearch case will initialize the index.
|