# How do fuzzy matching algorithms function within Sales Cloud duplicate rules to detect duplicates?

**Topic:** Sales Cloud · **Difficulty:** Medium · **Tags:** Sales Cloud, Duplicate Management, Fuzzy Matching

Read it on the site: https://www.forcechallenges.com/interview-questions/how-do-fuzzy-matching-algorithms-function-within-sales-cloud-duplicate-rules-to-detect-duplicates

## Answer

**Basics:** Exact matching compares values character for character. Fuzzy matching tolerates typos, nicknames, abbreviations and formatting differences, so "Bob Smith" and "Robert Smythe" or "Acme Inc." and "ACME Incorporated" can match. Salesforce ships standard matching rules for Account, Contact and Lead and lets you create custom ones.

**How it works:**
1. Matching rule: choose the object and define a matching equation made of field comparisons with Exact or Fuzzy methods (fuzzy options exist for name, company, street and similar fields; verify which fields support fuzzy).
2. Duplicate rule: link one to three matching rules, set conditions, and actions on create and on edit: Allow with alert, Allow with report, or Block; optionally limit by user or profile.
3. When a record is saved, Salesforce evaluates the matching rule against existing records and applies the action.
4. Matches are recorded in Duplicate Record Sets and Items for reporting; Duplicate Jobs scan existing data (higher editions).
5. Users merge duplicates (up to three records at a time).

**Advanced / deep dive:** Fuzzy algorithms combine techniques such as nickname libraries, phonetic and edit-distance logic, so they raise recall at the cost of false positives; test with real data and tune the equation. Blank fields can influence results depending on rule settings. Limits include up to five active duplicate rules per object (verify current numbers). Rules run on UI, API and import, but you can bypass with DMLOptions.DuplicateRuleHeader.allowSave. Cross-object matching (Lead to Contact) is supported through standard rules. Large volumes of cleaned data are better handled by dedicated tools or Data Cloud identity resolution.

**Code / config example:**
```apex
List<Lead> candidates = new List<Lead>{ new Lead(FirstName='Bob', LastName='Smith', Company='Acme Inc') };
List<Datacloud.FindDuplicatesResult> results = Datacloud.FindDuplicates.findDuplicates(candidates);
for (Datacloud.FindDuplicatesResult r : results)
  for (Datacloud.DuplicateResult d : r.getDuplicateResults())
    for (Datacloud.MatchResult m : d.getMatchResults())
      System.debug(m.getRule() + ' matches: ' + m.getSize());
```

**Hidden gotchas & must-remember points:**
- Matching rule defines "same"; duplicate rule defines the action.
- Block applies to API and integrations unless allowSave is set.
- Duplicate rules do not clean existing data; run a job or merge.
- Active rule counts per object are limited.
- Merge handles three records at once.
- findDuplicates has a per-call record limit; verify the current number.

**Best practice:** Start with Alert, review false positives for a few weeks, then move high-confidence rules to Block.

---
Source: ForceChallenges · last updated 2026-11-02
