Starting a new thread, continuing from this previous thread:
Conditional indexing, multiple indexes / fields within indexI'm currently migrating from 3.4 to 4.0.0 alpha. The framework wrt index sharding changed in this new release, and now deals with IndexManagers instead of DirectoryProviders.
Changing the sharding strategy won't be that hard, just a matter of change in type if I look at the new
CustomerShardingStrategy used in the tests.
Next problem I will have is to get the IndexManager for a specific shard (or 'namespace' in my case). The
current 4.0 documentation doesn't show an example for getting an IndexManager. Not sure, but it seems that I currently need to cast the SearchFactory to an instance of
SearchFactoryImplementor to have access to an index manager?
What I'm trying to accomplish is to get an IndexReader that uses a selection of shard. In HS3.4 it looked like this:
Code:
public IndexReader getReader() {
SearchFactory searchFactory = getFullTextSession().getSearchFactory();
DirectoryProvider<?>[] providers = searchFactory
.getDirectoryProviders(entityClass); // <-- How to get the index managers in 4.0 ?
if(namespaceConstraint.isEmpty()) {
return searchFactory.getReaderProvider().openReader(providers);
} else {
int index = directoryProviderIndexForNamespace();
return searchFactory.getReaderProvider().openReader(providers[index]);
}
}
How should I do this in HS4.0? Maybe there is already a better way to get an index reader using filters, that uses the sharding strategy (similar to what is done at query time)?
Thanks again :)