Searching for symbols

This recipe demonstrates how to make symbols searchable in a dtSearch index. It also demonstrates how to use regular expressions to search for certain symbols reserved as search operators, such as the % sign.

Requirements

  • Workspace access
  • Search index – Edit/Add and corresponding tab

Directions

  1. Create a dtSearch index.
  2. Update the alphabet file to include the % sign as an indexed character:
    1. Enter the following under [Letters] // Original letter, lower case, upper case, unaccented:
      1. [Space] [%] [Space] [%] [Space] [%] [Space] [%]

        Note: You must have a leading space. You can't have a trailing space.

        Alphabet file with symbols

    2. Delete the % sign from the [Ignore] section.

      Before:

      The [Ignore] section of the alphabet file with the percent sign included.

      After:

      The [Ignore] section of the alphabet file with the percent sign deleted.

    3. Repeat these steps for any other symbols that you need to make indexed. Delete the appropriate symbols from the [Spaces], [Ignore], or [Hyphens] sections.
  3. Perform a full build of the dtSearch index.

You can now search for terms containing the % sign using a regular expression. For example, if you need to search for documents that contain the term 75%, you would enter the following in your search box (ensuring you select the proper dtSearch index):

"##75\u0025"

To break this regular expression down:

  • ## signals to Relativity to treat the string as a regular expression
  • \u indicates a search using a character's Unicode value (to follow in the next four characters)
  • 0025 indicates the hexadecimal Unicode value for the % sign.

Note: For most symbols, once you have indexed the character in the alphabet file, you can type them directly into the dtSearch box without using regular expressions. Thus to search for 30!, enter 30! into the dtSearch box after you have made ! an indexed character. You only need to employ RegEx for certain symbols.

For characters outside of the ASCII code range, such as § and £, you cannot make them searchable by adding them to the letters section. Instead, create an AdditionalLetters section at the bottom of the alphabet file and insert the characters' Unicode value.

Symbol searching quick reference

Use the following table to quickly reference how to search for special characters:

Symbols Directions Example search term Example search string
$ @ \ / + , . ; - ' ` ! < > { } ^ _ { } | Update the alphabet file and search.
  • $75
  • @75
  • $75
  • @75
? * ( ) # = Update the alphabet file and use RegEx with an escape character (\).
  • #75
  • 75?
  • "##\#75"
  • "##75\?"
" % & : ~

Update the alphabet file and use RegEx with the hexadecimal Unicode value.

  • 75~
  • "##75\u007e"
Characters outside the ASCII code range such as § and £ Create an AdditionalLetters section at the bottom of the alphabet file and insert the character's Unicode value.
  • £75
  • £75

Watch the following Recipe - How to Adjust the dtSearch Alphabet File for Symbols video.

References