Boolean operators allow conditional search results

  • Release version: Xanadu
  • Updated August 1, 2024
  • 2 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Boolean operators allow conditional search results

    Boolean operators enable you to perform complex and conditional searches across all global text search interfaces within ServiceNow, including the global text search field, Knowledge Base searches, and list searches for text. These operators—AND, OR, and NOT—help refine search results by combining or excluding specific terms.

    Show full answer Show less

    Important: Boolean operators are case-sensitive. For example, "OR" is recognized as an operator, while "Or" or "or" are treated as plain search terms.

    Key Features

    • OR Operator (OR or |): Finds matches if any of the specified terms exist, effectively performing a union of search sets. For example, searching for "email password" OR email retrieves documents containing either phrase.
    • AND Operator: Finds matches only if all specified terms exist, performing an intersection of search sets. For example, "CPU load" AND "10 minutes" returns documents containing both phrases. By default, terms entered without explicit operators are combined with AND.
    • NOT Operator (NOT, -, !): Excludes documents containing the specified term immediately following the operator. For example, "CPU load" NOT "10 minutes" excludes documents with "10 minutes". Note that NOT must stand alone and cannot be used to exclude all search terms.

    Practical Considerations for ServiceNow Customers

    • When building filters with condition builders, using the .or. operator on fields other than Keywords can yield different results than using the Boolean OR in keyword searches.
    • Only one Keywords filter condition is allowed per condition set; using OR filters disables Keywords field selection and vice versa.
    • For Knowledge Base searches, if the default AND search yields poor results, the system automatically retries using OR. Administrators can configure this behavior via the glide.knowman.search.operator system property.
    • Quotation marks can be used to search exact phrases, and wildcard characters allow pattern matching (covered in related concepts).

    Benefits

    Utilizing Boolean operators in your ServiceNow searches enables you to:

    • Construct precise queries that efficiently filter data and documents relevant to your needs.
    • Combine multiple search terms flexibly to broaden or narrow your search scope.
    • Exclude irrelevant results, enhancing search result quality and saving time.

    Construct complex searches using Boolean AND, OR, and NOT operators in global text searches.

    You can use Boolean operators in all global text search interfaces:
    • Global text search field
    • Knowledge Base search
    • List search for text
    Note:
    Boolean operators are case-sensitive. As an example, the system recognizes OR as a Boolean operator, but treats Or and or as regular search terms.
    Table 1. Boolean operators
    Operator Description
    OR or vertical bar symbol (|) Finds a match if any of the search terms exist in a document (a union of sets). For example, to find documents that contain either email password or just email, you can search for "email password" OR email or "email password"|email.
    Using the .or. operator, which the system uses when you create OR condition groups for fields other than Keywords with the condition builder, can produce different results. For example, this filter searches for records with short descriptions containing SSO and then searches separately for records with short descriptions containing SAML:
    Figure 1. Searching with the filter choice lists
    Searching with the filter choice lists.
    Note:
    By design, you can only have one Keywords filter condition per condition set. If you select the Keywords field in a filter choice list, the OR button for that filter condition becomes unavailable. Similarly, if you construct an OR filter condition, the Keywords field becomes unavailable in the filter choice lists.
    AND Finds a match if all search terms exist in a document (an intersection of sets). For example, to find documents that contain both "CPU load" and "10 minutes", search for "CPU load" AND "10 minutes"
    By default, Zing applies an AND operator between all search terms not separated by OR or NOT operators. For example, if you enter email server down as your search terms, the system searches for email AND server AND down.
    Note:
    For Knowledge Base searches, if the default AND search returns poor results, the search is automatically re-run with the OR operator. Administrators can configure the knowledge base search to always use OR by modifying the glide.knowman.search.operator system property.
    NOT, minus (-), or exclamation point (!) Excludes documents that contain the search term after the NOT operator (a difference of sets). For example, to find documents that contain "CPU load" but not "10 minutes", you can search for "CPU load" NOT "10 minutes" or "CPU load" -"10 minutes" or "CPU load" !"10 minutes".

    NOT must be a stand-alone term in your search. For example, atom NOT ion excludes the term ion, but NOTION searches for the term notion.

    The minus and exclamation point symbols must immediately precede the search term that you want to exclude. For example, a search for email !Joe excludes Joe but a search for email ! Joe includes Joe.

    You can't use the NOT operator to exclude all terms in your search. For example, the following search returns no results: NOT "10 minutes".