There are a few code smells:
* Backend sub-components are mostly accessed through getters * Some components, such as the {{SearchQueryBuilder}} implementations, have a lot of constructor parameters, and sometimes the arguments are passed by components that only retrieve the value through a getter.
This seems to indicate that some concepts are spread throughout the codebase instead of being encapsulated. Some additional components could probably be introduced to simplify the code.
For instance a backend-scoped component dedicated to search that could be passed to index managers and used in place of the backend in SearchTargets. That component would have references to the work factory and query orchestrator, and would in particular allow to build a {{SearchQuery}}. It could also carry a reference to the multi-tenancy strategy (see HSEARCH-3119) and maybe even cache every hit extractor that relies solely on the multi-tenancy strategy (and used to be implemented as a singleton before HSEARCH-3119).
Also, we should probably move index intialization code (currently in {{org.hibernate.search.v6poc.backend.elasticsearch.index.impl.ElasticsearchIndexManagerBuilder#build}}) to a dedicated component, especially since there are plans to parallelize this initialization.
The two proposals above should allow to get rid of the Backend getters, but maybe some other components are missing.
This is true for both the Lucene backend and the Elasticsearch backend. |
|