* If the index is sharded, the Properties index matches the shard index
*
* @return an array of index properties
*/
private static Properties[] getIndexProperties(SearchConfiguration cfg, String indexName) {
Properties rootCfg = new MaskedProperty( cfg.getProperties(), "hibernate.search" );
Properties globalProperties = new MaskedProperty( rootCfg, "default" );
Properties directoryLocalProperties = new MaskedProperty( rootCfg, indexName, globalProperties );
String shardsCountValue = directoryLocalProperties.getProperty( NBR_OF_SHARDS );
if ( shardsCountValue == null ) {
// no shard finished.
return new Properties[] { directoryLocalProperties };
}
else {
// count shards
int shardsCount = ConfigurationParseHelper.parseInt(
shardsCountValue, "'" + shardsCountValue + "' is not a valid value for " + NBR_OF_SHARDS
);
if ( shardsCount <= 0 ) {
throw log.getInvalidShardCountException( shardsCount );
}
// 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;
}