Code Examples
dc3SearchResult
Example 1: Processing and logging duplicate search results
Demonstrates how to iterate through a list of dc3SearchResult
objects, log their scores, and retrieve display fields.
// Example of processing duplicate search results
Map<String, List<dupcheck.dc3SearchResult>> searchResults = [YOUR SEARCH LOGIC];
if (searchResults != null && !searchResults.isEmpty()) {
for (String objectPrefix : searchResults.keySet()) {
List<dupcheck.dc3SearchResult> results = searchResults.get(objectPrefix);
for (dupcheck.dc3SearchResult result : results) {
// Log the matching score and object name
System.debug('Matching Score: ' + result.score);
System.debug('Object Name: ' + result.getObjectName());
// Fetch and log the display fields
Map<String, Object> displayFields = result.getDisplayField();
System.debug('Display Fields: ' + displayFields);
}
}
} else {
System.debug('No duplicates found.');
}
Example 2: Sorting search results by score
Shows how to sort a list of dc3SearchResult
objects by their scores using the compareTo()
method.
// Example of sorting duplicate results by score
List<dupcheck.dc3SearchResult> duplicates = [YOUR SEARCH LOGIC];
duplicates.sort(); // Sorts based on the compareTo method implementation
for (dupcheck.dc3SearchResult result : duplicates) {
System.debug('Score: ' + result.score + ', Object Name: ' + result.getObjectName());
}
Example 3: Accessing scenario-specific scores
Demonstrates how to iterate over the scenarioScores
field to access the detailed breakdown of matching scores.
// Example of accessing scenario-specific scores
List<dupcheck.dc3SearchResult> duplicates = [YOUR SEARCH LOGIC];
for (dupcheck.dc3SearchResult result : duplicates) {
System.debug('Duplicate Object: ' + result.objectData);
System.debug('Overall Score: ' + result.score);
for (dupcheck.dc3SearchResult.ScenarioScore scenarioScore : result.scenarioScores) {
System.debug('Scenario ID: ' + scenarioScore.scenarioId);
System.debug('Scenario Name: ' + scenarioScore.scenarioName);
System.debug('Scenario Score: ' + scenarioScore.scenarioScore);
}
}
Updated about 1 month ago