Loading

Salesforce Search: Partial Search Terms May Not Return Results Due to Tokenization

Date de publication: Jun 21, 2026
Description

In Salesforce, users may find that searching for a partial value of a field does not return the expected results. This behavior is related to how Salesforce tokenizes data during the search indexing process.
Tokenization is the process by which Salesforce breaks field values into smaller segments (tokens) that are stored in the search index. Only full tokens — not arbitrary substrings — match search queries by default.
Important note: If a search query contains punctuation or special characters, try replacing the punctuation with white spaces. Also, tokenization behavior may differ by field type. For example, a phone number in a dedicated Phone field may be tokenized differently from the same number stored in a Chatter post.
Example scenario:
A car dealership representative needs to search for a customer record using the last 4 digits of a Vehicle Identification Number (VIN). The full VIN stored in the system is 1HGBH41JXMN109186.
Salesforce tokenizes this value as:

Indexed TermValid Search Tokens
1HGBH41JXMN1091861HGBH41JXMN109186
HGBH
41
JXMN
109186

When the representative searches for 9186 (the last 4 digits), no results appear. Appending a leading wildcard — such as *9186 — also does not return the expected record. Leading wildcards are only supported in Standard Lookups, which are available in Salesforce Classic UI only.
To return the correct record, the representative must use one of the valid tokens listed above.

Résolution
 
An example workaround for the scenario above is to create a custom field, workflow rule, and a workflow action to populate a searchable text field with the last 4 digits from the sample custom field, VIN# (VIN__c).


Step 1: Create a custom field

1. Steps for Classic: Setup | Customize | Object | Fields | New.
    Steps for Lightning: Setup | Object Manager | Object | Fields & Relationships | New.
2. Choose an appropriate Field Label, Length, and Description (optional). Click Next.
3. Select the Visible check box twice (this would make the field hidden). Click Next.
4. Deselect Add Field in Step 4. Add to page layouts. Click Save.
 

Step 2: Create a workflow rule

1. Steps for Classic: Setup | Create | Workflow & Approvals | Workflow Rules.
    Steps for Lightning: Setup |Process Automation | Workflow Actions | Workflow Rules.
2. Click on New Rule. Select the standard or custom object from the Object dropdown then click Next.
3. Give an appropriate Rule Name & Description (optional).
4. Select created, and every time it’s edited under Evaluation Criteria.
5. Under Rule Criteria, select formula evaluates to true on the dropdown for 'Run this rule if the.'
6. Enter 1<>0 in the formula editor then click Save & Next.


Step 3: Create a workflow action

  1. Under Immediate Workflow Actions, click on Add Workflow Action and select New Field Update.
  2. Enter a Name, Unique Name, and Description (optional).
  3. Select the custom field you created in step 1.
  4. Under Specify New Field Value, select Use a formula to set the new value.
  5. Click Show Formula Editor, click on Insert Field, enter Left(VIN__c , 4) then click Save.
  6. Click on Done then Activate.

Now, navigate to the record that wasn't part of your search result and perform a simple edit and save (no need to make any changes on the record, this step is done to fire the workflow action & re-index the record). Note that the record is now returned in the search result when you search for just the 4 digits of the VIN#.
Numéro d’article de la base de connaissances

000383915

 
Chargement
Salesforce Help | Article