Questo contenuto non è disponibile nella lingua selezionata.
Chapter 1. Defining a default index that applies to all newly created databases
The default index in Directory Server defines a set of attributes to be indexed. When you create a new database, Directory Server copies the default index attributes from cn=default indexes,cn=config,cn=ldbm database,cn=plugins,cn=config
entry to the database-specific cn=index,cn=database_name,cn=ldbm database,cn=plugins,cn=config
entry.
Directory Server does not apply changes in the default index to existing databases.
1.1. The different index types
Directory Server stores the indexes of each indexed attribute in a separate database file in the instance’s database directory. For example, the indexes of the sn
attribute are stored in the /var/lib/dirsrv/slapd-instance_name/db/database_name/sn.db
file. Each index file can contain multiple index types if Directory Server maintains different indexes for an attribute.
Directory Server supports the following index types:
-
The presence index (
pres
) is a list of the entries that contain a particular attribute. For example, use this type when clients frequently perform searches, such asattribute=mail
. -
The equality index (
eq
) improves searches for entries containing a specific attribute value. For example, an equality index on thecn
attribute enables faster searches forcn=first_name last_name
. -
The approximate index (
approx
) enables efficient approximate or sounds-like searches. For example, searches forcn~=first_name last_name
,cn~=first_name
, orcn~=first_nam
(note the misspelling) would return an entrycn=first_name X last_name
. Note that the metaphone phonetic algorithm in Directory Server supports only US-ASCII letters. Therefore, use approximate indexing only with English values. -
The substring index (
sub
) is a costly index to maintain, but it enables efficient searching against substrings within entries. Substring indexes are limited to a minimum of three characters for each entry. For example, searches fortelephoneNumber=*555*
return all entries in the directory with a value that contains555
in thetelephoneNumber
attribute. - International index speeds up searches for information in international directories. The process for creating an international index is similar to the process for creating regular indexes, except that it applies a matching rule by associating an object identifier (OID) with the attributes to be indexed.
1.2. Balancing the benefits of indexing
Before you create new indexes, balance the benefits of maintaining indexes against the costs:
- Approximate indexes are not efficient for attributes commonly containing numbers, such as phone numbers.
- Substring indexes do not work for binary attributes.
- Avoid equality indexes on attributes that contain big values, such as an image.
- Maintaining indexes for attributes that are not commonly used in searches increases the overhead without improving the search performance.
- Attributes that are not indexed can still be used in search requests, although the search performance can be degraded significantly, depending on the type of search.
Indexes can become very time-consuming. For example, if Directory Server receives an add operation, the server examines the indexing attributes to determine whether an index is maintained for the attribute values. If the created attribute values are indexed, Directory Server adds the new attribute values to the index, and then the actual attribute values are created in the entry.
Example 1.1. Indexing steps Directory Server performs when a user adds an entry
Assume that Directory Server maintains the following indexes:
-
Equality, approximate, and substring indexes for the
cn
andsn
attributes. -
Equality and substring indexes for the
telephoneNumber
attribute. -
Substring indexes for the
description
attribute.
For example, a user adds the following entry:
dn: cn=John Doe,ou=People,dc=example,dc=com objectclass: top objectClass: person objectClass: orgperson objectClass: inetorgperson cn: John Doe cn: John sn: Doe ou: Manufacturing ou: people telephoneNumber: 408 555 8834 description: Manufacturing lead
When the user adds the entry, Directory Server performs the following steps:
-
Create the
cn
equality index entry forJohn
andJohn Doe
. -
Create the
cn
approximate index entries forJohn
andJohn Doe
. -
Create the
cn
substring index entries forJohn
andJohn Doe
. -
Create the
sn
equality index entry forDoe
. -
Create the
sn
approximate index entry forDoe
. -
Create the
sn
substring index entry forDoe
. -
Create the
telephoneNumber
equality index entry for408 555 8834
. -
Create the
telephoneNumber
substring index entry for408 555 8834
. -
Create the
description
substring index entry forManufacturing lead
.
This example illustrates that the number of actions required to create and maintain databases for a large directory can be very resource-intensive.
Do not define a substring index for membership attributes (for example, member
,uniquemember
) because it can impact Directory Server performance. When adding or removing members, for example,uniquemember
to a group with many members, the computation of the uniquemember
substring index requires to evaluating all uniquemember
values and not only added or removed values.
1.3. Default index attributes
Directory Server stores the default index attributes in the cn=default indexes,cn=config,cn=ldbm database,cn=plugins,cn=config
entry. To display them, including their index types, enter:
# ldapsearch -D "cn=Directory Manager" -W -H ldap://server.example.com -b "cn=default indexes,cn=config,cn=ldbm database,cn=plugins,cn=config" -s one -o ldif-wrap=no
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Removing the attributes listed in the table (system indexes) from the index of databases can significantly affect the Directory Server performance.
1.4. Maintaining the default index
Directory Server stores the default index attributes in the cn=default indexes,cn=config,cn=ldbm database,cn=plugins,cn=config
entry. Note that you can only maintain the default index attributes using LDIF statements.
Procedure
For example, to add the
roomNumber
attribute to the default index with the index typeseq
andsub
, enter:#
ldapadd -D "cn=Directory Manager" -W -H ldap://server.example.com -x
dn: cn=roomNumber,cn=default indexes,cn=config,cn=ldbm database,cn=plugins,cn=config objectClass: nsIndex objectClass: top cn: roomNumber nsSystemIndex: false nsIndexType: eq nsIndexType: subExplanation of the LDIF statement:
-
objectClass: nsIndex
: Defines that this entry is an index entry. -
objectClass: top
: This object class is additionally required in index entries. -
cn
: Sets the name of the attribute to index. -
nsSystemIndex
: Indicates whether or not the index is essential to Directory Server operations. -
nsIndexType
: This multi-value attribute specifies the index types.
-
For example, to add the
pres
index type to the default index attributes of theroomNumber
attribute, enter:#
ldapmodify -D "cn=Directory Manager" -W -H ldap://server.example.com -x
dn: cn=roomNumber,cn=default indexes,cn=config,cn=ldbm database,cn=plugins,cn=config changetype: modify add: nsIndexType nsIndexType: presFor example, to remove the
pres
index type from the default index attributes of theroomNumber
attribute, enter:#
ldapmodify -D "cn=Directory Manager" -W -H ldap://server.example.com -x
dn: cn=roomNumber,cn=default indexes,cn=config,cn=ldbm database,cn=plugins,cn=config changetype: modify delete: nsIndexType nsIndexType: presFor example, to remove the
roomNumber
attribute from the default index, enter:#
ldapdelete -D "cn=Directory Manager" -W -H ldap://server.example.com -x cn=roomNumber,cn=default indexes,cn=config,cn=ldbm database,cn=plugins,cn=config
Verification
List the default index attributes to verify your changes:
#
ldapsearch -H ldap://server.example.com:389 -D "cn=Directory Manager" -W -b "cn=default indexes,cn=config,cn=ldbm database,cn=plugins,cn=config" -x -s one -o ldif-wrap=no