* hibernate.search.indexname.n has priority over hibernate.search.indexname which has priority over hibernate.search.default
* If the Index is not sharded, a single Properties is returned
* If the index is sharded, the Properties index matches the shard index
*/
private static Properties[] getDirectoryProperties(SearchConfiguration cfg, String directoryProviderName) {
Properties rootCfg = new MaskedProperty( cfg.getProperties(), "hibernate.search" );
Properties globalProperties = new MaskedProperty( rootCfg, "default" );
Properties directoryLocalProperties = new MaskedProperty( rootCfg, directoryProviderName, globalProperties );
final String shardsCountValue = directoryLocalProperties.getProperty( NBR_OF_SHARDS );
if ( shardsCountValue == null ) {
// no shards: finished.
return new Properties[] { directoryLocalProperties };
}
else {
// count shards
int shardsCount = ConfigurationParseHelper.parseInt(
shardsCountValue, shardsCountValue + " is not a number"
);
// create shard-specific Props
Properties[] shardLocalProperties = new Properties[shardsCount];
for ( int i = 0; i < shardsCount; i++ ) {
shardLocalProperties[i] = new MaskedProperty(
directoryLocalProperties, Integer.toString( i ), directoryLocalProperties
);
}
return shardLocalProperties;
}