Defines a database table's index.

Using the properties on this class, you can:

  • Control which tablespace/filegroup contains the index.
  • Specify the order of the columns in the index.
  • Specify that an index is unique.
  • Indicate whether the index is case-insensitive or not (on supporting configurations).

Note that these properties are all SETTABLE_ONLY_ON_CREATE. Therefore, instances of CmIndexDefinition are immutable once created. To change an index, you must delete the existing CmIndexDefinition instance (which results in the index being dropped from the database), and then create a new instance with the required changes.

If you create a CmIndexDefinition object for a manually created index (an index that a database administrator created using the native database tools), the name specified for the CmIndexDefinition object must be the same as the name for the manually created index. The server will detect that the physical index already exists and, in such cases, will update only the metadata in the tables (skipping the actual index creation but performing the index definition creation).

ToggleExamples

The following code creates a unique index on the columns representing the two properties cr1s, cr5s of the myCustomClass class. The columns appear in the index in the same order as the properties appear in the class definition.
              // Get TableDefinition to add compound index.
              IClassDefinition classDef= Factory.ClassDefinition.FetchInstance(os, "myCustomClass", null);
              ITableDefinition td = classDef.TableDefinition;
              // Create CmIndexedColumnList for columns to be indexed.
              ICmIndexedColumnList indCols = Factory.CmIndexedColumn.CreateList();
              // Get PropertyDefinitions from class.
              IPropertyDefinitionList propDefs = classDef.PropertyDefinitions;
              
              // Iterate PropertiesDefinitionList in search of properties 
              // that correspond with the two columns to be indexed.
              foreach(IPropertyDefinition propDef in propDefs)
              {
                   if (propDef.SymbolicName.Equals("cr1s", StringComparison.OrdinalIgnoreCase)
                       || propDef.SymbolicName.Equals("cr5s", StringComparison.OrdinalIgnoreCase))
                   {
                       String propName=propDef.SymbolicName;
                       // Iterate column definitions to add target columns to list.
                       IColumnDefinitionList colDefs = td.ColumnDefinitions;
                       foreach(IColumnDefinition colDef in colDefs)
                       {
                            if (propDef.ColumnId.Equals(colDef.Id))
                            {
                                ICmIndexedColumn indCol = Factory.CmIndexedColumn.CreateInstance();  
                                indCol.ColumnName = colDef.ColumnName;
                                  SortOrder sortValue = propName.Equals("cr1s") ? SortOrder.ASCENDING 
                                                        : SortOrder.DESCENDING;
                                indCol.SortOrder = sortValue;
                                indCols.Add(indCol);
                                break;
                            }
                       }
                   }
              }
              
              // Create CmIndexDefinition and set columns to be indexed and other properties.
              ICmIndexDefinitionList indDefs = td.IndexDefinitions;
              ICmIndexDefinition indDef = Factory.CmIndexDefinition.CreateInstance();
              indDef.RequiresUniqueElements = true;
              indDef.ForCaseInsensitiveSearch = false;
              indDef.IndexedColumns = indCols;	
              indDefs.Add(indDef);
              
              // Set index definition on table and save.
              td.IndexDefinitions = indDefs;
              td.Save(RefreshMode.NO_REFRESH);
              

Namespace:  FileNet.Api.Admin
Assembly:  FileNet.Api (in FileNet.Api.dll)

ToggleSyntax

Visual Basic (Declaration)
Public Interface ICmIndexDefinition _
	Implements IRepositoryObject, IEngineObject, ICloneable, IDependentObject
C#
public interface ICmIndexDefinition : IRepositoryObject, 
	IEngineObject, ICloneable, IDependentObject
Visual C++
public interface class ICmIndexDefinition : IRepositoryObject, 
	IEngineObject, ICloneable, IDependentObject
JavaScript
FileNet.Api.Admin.ICmIndexDefinition = function();
FileNet.Api.Admin.ICmIndexDefinition.createInterface('FileNet.Api.Admin.ICmIndexDefinition');

ToggleRemarks

Metadata

Auditable: false
AllowsInstances: true
AllowsSubClasses: false
ClassDefinitionName: None
IsDependent: true
IsHidden: false
Searchable: false
StorageType: ObjectStore
SuperclassName: GenericObject

ToggleSee Also