This chapter describes search filters and how searches work.
To narrow a search, you can specify search filters directly to the Smart Search field. If the search field contains an equal sign (=), Smart Search assumes the value is a search filter, and it uses this filter directly to perform the search.
Search filters use the value of an attribute to select the entries to be returned for Smart Search. For example, the following filter specifies a search for a common name equal to Babs Jensen:
cn=babs jensen
The basic syntax of a search filter is:
attribute operator value
employeenumber >= 100
In the example above, employeenumber is the attribute, >= is the operator, and 100 is the value.
You can also define filters that use combinations of different attributes.
When searching for an entry, you can specify attributes associated with that type of entry. For example, when you search for entries about people, you can use the cn attribute to search for people with specific common names.
Examples of attributes for entries about people might include:
For a listing of the attributes associated with entries, see Appendix A, "Entries and attribute fields". Note that you need to use the internal attribute names in search filters.
An operator defines one of the following types of searches:
For more information on these types of searches, see "How searching works."
You can combine different search filters by using boolean operators. Use the operators in prefix notation as follows:
(boolean_operator((filter)(filter)(filter)...))
where boolean_operator is any one of the boolean operators. For example:
(&(ou=Marketing)(cn=Ray*))
In the example above, the combination of filters finds entries whose organizational unit is Marketing (ou=Marketing) and whose common name starts with Ray (cn=Ray*). The boolean operator for "And" (&) is used in prefix notation, which means that it precedes the search criteria.
In addition, you can nest boolean operators to form complex expressions, such as:
(boolean_operator(filter)((boolean_operator(filter)(filter)))
The boolean operators available for use with search filters are:
The following filter searches for entries containing the manager attribute. This is also known as a presence search:
manager=*
The following filter searches for entries containing the common name of Ray Kultgen. This is also known as an equality search:
cn=Ray Kultgen
The following filter returns any entries that do not contain the common name of Ray Kultgen:
(!(cn=Ray Kultgen))
The following filter returns any entries that contain a description attribute with a substring of X.500:
description=*X.500*
The following filter returns any entries whose organizational unit is Marketing and whose description field does not contain the substring X.500:
(&(ou=Marketing)(!(description=*X.500*)))
The following filter returns any entries whose organizational unit is Marketing and who have Julie Fulmer or Cindy Zwaska as a manager:
(&(ou=Marketing)(|(manager="cn=Julie Fulmer,ou=Marketing,o=Example Corp,c=US")
(manager="cn=Cindy Zwaska,ou=Marketing,o=Example Corp,c=US")))
The following filter returns any entries that do not represent a person:
(!(objectclass=person))
The following filter returns any entries that do not represent a person and whose common name is approximately printer3b:
(&(!(objectclass=person))(cn~=printer3b))
Note:
The Directory Server interface is actually a collection of forms and CGI programs that operate independently from the Directory Server. This interface acts as an LDAP client to the Directory Server.
The following section explains what happens when you search the Directory Server:
Your administrator can configure these settings. For more detailed information on the searching algorithm, see the Directory Server Administrator's Guide.
The rest of this section explains how approximate searches work and how substring searches work.
The approximate search finds a word that "sounds like" the value you enter. In the Advanced Search interface, the approximate search corresponds to the "sounds like" search type.
For example, an entry may include the attribute value cn=Robert E Lee. An approximate search allows you to find this entry by specifying Robert Lee, Robert, or Lee. Similarly, a search for the location approximately equal to San Fransico (l~=San Fransico; note the misspelling) would return entries including locations exactly equal to San Francisco (l=San Francisco).
The Directory Server treats each value in an entry as a sequence of words and generates a phonetic code for each word. When you enter a value in an approximate search, the Directory Server also translates the value to a sequence of phonetic codes. An entry is considered to match a query if:
The substring search finds entries that contain the value you have entered. In the Advanced Search interface, the substring search corresponds to the "starts with", "contains", and "ends with" search types.
For example, searches of the form:
would match the common names containing strings such as:
Bill Anderson Jill Anderson Steve Sanderson
and so forth. Similarly, the search for
would return all the entries in your directory with telephone numbers that contain 555.