public OIndex<?> createIndex(final String name, String type, final OProgressListener progressListener, ODocument metadata,
String algorithm, final String... fields) {
if (type == null)
throw new IllegalArgumentException("Index type is null");
type = type.toUpperCase(Locale.ENGLISH);
if (fields.length == 0) {
throw new OIndexException("List of fields to index cannot be empty.");
}
final String localName = this.name;
final int[] localPolymorphicClusterIds = polymorphicClusterIds;
for (final String fieldToIndex : fields) {
final String fieldName = decodeClassName(OIndexDefinitionFactory.extractFieldName(fieldToIndex));
if (!fieldName.equals("@rid") && !existsProperty(fieldName))
throw new OIndexException(
"Index with name '" + name + "' cannot be created on class '" + localName + "' because the field '" + fieldName
+ "' is absent in class definition");
}
final OIndexDefinition indexDefinition = OIndexDefinitionFactory
.createIndexDefinition(this, Arrays.asList(fields), extractFieldTypes(fields), null, type, algorithm);
return getDatabase().getMetadata().getIndexManager()
.createIndex(name, type, indexDefinition, localPolymorphicClusterIds, progressListener, metadata, algorithm);
}