13.3. Generating New Indexes to Existing Databases

New indexes are not added to existing databases automatically. They must be added manually, and Directory Server has two methods for generating new indexes to an existing database: running the db2index.pl script or running a cn=index,cn=tasks task.

Important

Before you regenerate the index, searches will fail.

13.3.1. Running the db2index.pl Script

After creating an indexing entry or adding additional index types to an existing indexing entry, run the db2index.pl script to generate the new set of indexes to be maintained by the Directory Server. After the script is run, the new set of indexes is active for any new data added to the directory and any existing data in the directory.
Run the db2index.pl Perl script.
# db2index.pl -Z instance_name -D "cn=Directory Manager" -w secret -n ExampleServer -t sn
For more information about using this Perl script, see the Red Hat Directory Server Configuration, Command, and File Reference.
For information about the parameters used in the example, see the description of the db2index utility in the Red Hat Directory Server Configuration, Command, and File Reference.

13.3.2. Using a cn=tasks Entry to Create an Index

The cn=tasks,cn=config entry in the Directory Server configuration is a container entry for temporary entries that the server uses to manage tasks. Several common directory tasks have container entries under cn=tasks,cn=config. Temporary task entries can be created under cn=index,cn=tasks,cn=config to initiate an indexing operation.
This task entry requires a unique name (cn) and a definition for the attribute and type of index, set in nsIndexAttribute in the format attribute:index_type.
For example:
# ldapmodify -a -D "cn=Directory Manager" -W -p 389 -h server.example.com -x

dn: cn=example presence index,cn=index,cn=tasks,cn=config
changetype: add
objectclass: top
objectclass: extensibleObject
cn: example presence index
nsInstance: userRoot
nsIndexAttribute: "cn:pres"
There are three possible index_types:
  • pres for presence indexes
  • eq for equality indexes
  • sub for substring indexes
As soon as the task is completed, the entry is removed from the directory configuration.
For details about the attributes used in the example and other attributes you can set in this entry, see the cn=task_name,cn=index,cn=tasks,cn=config entry description in the Red Hat Directory Server Configuration, Command, and File Reference.