Chapter 3. Changing the search key length in a substring index
By default, the length of the search key for substring indexes must be at least three characters. For example, Directory Server will add the string abc
as a search key to an index while ab*
will not. However, to improve the search performance, particularly for searches with many wildcard characters, you can shorten the search key length. This increases the number of search keys in the index.
Directory Server has three attributes that change the minimum number of characters required for a search key:
-
nsSubStrBegin
: Sets the minimum number of characters for the beginning of a search key, before the wildcard character. For example:
abc*
-
nsSubStrMiddle
: Sets the minimum number of characters in the search key between wildcard characters. For example:
*abc*
-
nsSubStrEnd
: Sets the number of characters for the end of a search key, after the wildcard character. For example:
*xyz
3.1. Changing the search key length in a substring index using the command line
You can improve search speeds by setting a new search key length for an attribute index.
Procedure
To set new search key length, add the
extensibleObject
object class and then add thensSubStrBegin
,nsSubStrEnd
, ornsSubStrMiddle
attributes to the entry. For example:# ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x dn: attribute_name,cn=index,cn=database_name,cn=ldbm database,cn=plugins,cn=config changetype: modify add: objectclass objectclass: extensibleObject - add: nsSubStrBegin nsSubStrBegin: 2 - add: nsSubStrMiddle nsSubStrMiddle: 2 - add: nsSubStrEnd nsSubStrEnd: 2
Recreate the index to apply new setting. For example, while the Directory Server instance is running, use the following command to recreate the index for the specified attribute:
# dsconf -D "cn=Directory Manager" ldap://server.example.com backend index reindex --attr attribute_name database_name
Verification
-
Select the attribute for which you want to change the search key length, for example,
cn
. Dump the
cn
index:dbscan -D bdb -f /var/lib/dirsrv/slapd-instance/db/database/cn.db > /tmp/default_len
- Configure the new search key length as described in section Changing the search key length in a substring index using the command line.
Stop the instance to synchronize the database on the disk:
# dsctl instance_name stop
Dump the
cn
index:dbscan -D bdb -f /var/lib/dirsrv/slapd-instance/db/database/cn.db > /tmp/len_2
Compare
len_2
anddefault_len
files:diff /tmp/len_2 /tmp/default_len