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*
abc*
-
nsSubStrMiddle: Sets the minimum number of characters in the search key between wildcard characters. For example:
*abc*
*abc*
-
nsSubStrEnd: Sets the number of characters for the end of a search key, after the wildcard character. For example:
*xyz
*xyz
3.1. Changing the search key length in a substring index using the command line Copy linkLink copied to clipboard!
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
extensibleObjectobject class and then add thensSubStrBegin,nsSubStrEnd, ornsSubStrMiddleattributes to the entry. For example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Recreate the index to apply the new setting. For example, while the Directory Server instance is running, use the following command to recreate the index for the specified attribute:
dsconf <instance_name> backend index reindex --attr <attribute_name> <database_name>
# dsconf <instance_name> backend index reindex --attr <attribute_name> <database_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
-
Select the attribute for which you want to change the search key length, for example,
cn. Dump the
cnindex:On an instance with Berkeley Database (BDB), run:
dbscan -D bdb -f /var/lib/dirsrv/slapd-<instance_name>/db/database/cn.db > /tmp/default_len
# dbscan -D bdb -f /var/lib/dirsrv/slapd-<instance_name>/db/database/cn.db > /tmp/default_lenCopy to Clipboard Copied! Toggle word wrap Toggle overflow On an instance with Lightning Memory-Mapped Database (LMDB), run:
dbscan -D mdb -f /var/lib/dirsrv/slapd-<instance_name>/db/database/cn.db > /tmp/default_len
# dbscan -D mdb -f /var/lib/dirsrv/slapd-<instance_name>/db/database/cn.db > /tmp/default_lenCopy to Clipboard Copied! Toggle word wrap Toggle overflow
- 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
# dsctl <instance_name> stopCopy to Clipboard Copied! Toggle word wrap Toggle overflow Dump the
cnindex:On an instance with Berkeley Database (BDB), run:
dbscan -D bdb -f /var/lib/dirsrv/slapd-<instance_name>/db/database/cn.db > /tmp/len_2
# dbscan -D bdb -f /var/lib/dirsrv/slapd-<instance_name>/db/database/cn.db > /tmp/len_2Copy to Clipboard Copied! Toggle word wrap Toggle overflow On an instance with Lightning Memory-Mapped Database (LMDB), run:
dbscan -D mdb -f /var/lib/dirsrv/slapd-<instance_name>/db/database/cn.db > /tmp/len_2
# dbscan -D mdb -f /var/lib/dirsrv/slapd-<instance_name>/db/database/cn.db > /tmp/len_2Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Compare
len_2anddefault_lenfiles:diff /tmp/len_2 /tmp/default_len
# diff /tmp/len_2 /tmp/default_lenCopy to Clipboard Copied! Toggle word wrap Toggle overflow