Programmatic Index Management with LDAP#

Indexes can be defined and managed using LDAP. The advantage to allowing index creation through LDAP is that an application can now define indexes during its install process. Index definitions can be part of the same LDIF file that applies the required schema for the application.

Adding a Index#

Using the command shown below with the ldapmodify utility creates a substring index on the fullName attribute.
ldapmodify -h -b -D "cn=admin, o=novell"" -w "ldap" dn: cn=testServer-NDS, o=Novell"
changetype: modify
add: indexDefinition
indexDefinition: 0$fullNameSubstring$2$2$0$1$fullName

Notice that the '$' character is used to separate the various fields in the value. If you use an index name or an attribute name that contains a '$' character, you must escape the '$'. In LDAP, inserting the character sequence \24 does this. The backslash is the escape character, and it must be followed by two octets specifying the nibbles of the escaped character. Since the $ character has a HEX value of 24, the octet representation of the escaped sequence is \24 (or, if you prefer, 5C3234).

If you choose to put UTF8 extended characters (not recommended) in one of the two text fields, they must also be escaped.

Listing Indexes#

The following command using the ldapsearch process provides all of the values of the indexDefinition attribute:
ldapsearch -h -L -D "cn=admin, o=novell" " -w "ldap"  -b "cn=testServer-NDS, o=Novell"" (indexDefinition = *) indexDefinition

Programmatically change the Index State#

LDAP can also be used to programmatically change the state of a defined index. Normally you would want to query the indexDefinition attribute to determine the current Index State, then modify the Index State field to either 0 to suspend it or 2 to start bringing it online. You should never change the state to either Bringing Online or Pending Creation. This is done automatically by a background process.

The following command to ldapmodify changes the state of the fullNameSubstring index from Online to Suspended.

ldapmodify -h -b -D "cn=admin, o=novell"" -w "ldap" dn: cn=testServer-NDS, o=Novell"
changetype: modify
delete: indexDefinition
indexDefinition: 0$fullNameSubstring$2$2$0$1$fullName
add: indexDefinition
indexDefinition: 0$fullNameSubstring$0$2$0$1$fullName

Managing Indexes#

You can export your perfectly setup Indexes from one server and import them into other server or use the same methodology when creating a new server to ensure you have the same indexes as on your other servers.

More Information#

There might be more information for this subject on one of the following:

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-4) was last changed on 04-Aug-2016 12:37 by jim