Change Detection Rules
Detailed guide on how Kadoa’s change detection algorithm classifies objects as changed, added, or removed
Algorithm Overview
The change detection process follows a three-phase matching algorithm:
- Exact Matches: Find objects that are completely identical (with whitespace normalization)
- Partial Matches: Find objects that are similar enough to be considered the same but with changes
- Leftovers: Classify remaining objects as either new or removed
Whitespace Normalization
All string comparisons use whitespace normalization to avoid false positives:
- Leading and trailing whitespace is trimmed
- Multiple consecutive whitespace characters are replaced with single spaces
- Different types of whitespace (tabs, newlines) are converted to standard spaces
Phase 1: Exact Matches
Objects are considered unchanged if they match exactly across all fields after whitespace normalization:
Result: unchanged
- No notification sent (whitespace differences ignored)
Phase 2: Partial Matches (Changed Objects)
Objects are considered changed if they meet either of these criteria:
Key Field Matching (When Configured)
When key fields are configured in your monitoring setup, objects are matched based on these fields. ALL key fields must match for objects to be considered the same:
Result: changed
- ID key field matches, so it’s the same object with updates
Key Field Behavior:
- Key fields are defined in your monitoring configuration with
isKeyField: true
- Common key fields include:
id
,url
,link
,title
- If ANY key field changes, objects are treated as
removed
+added
(notchanged
) - Key field matching ignores whitespace differences
Traditional Field Match Ratio (Default Method)
When no key fields are configured, objects are considered the same if they share >50% of their fields:
Field Match Calculation: 2 out of 3 fields match = 66.7% > 50%
Result: changed
- Field match ratio exceeds threshold
Important Notes:
- Only string fields are considered in the ratio calculation
- Empty fields and non-string values are excluded from matching
- Objects with different field structures can still match if the ratio is high enough
Phase 3: New and Removed Objects
Objects that don’t match in the previous phases are classified as:
New Objects
Objects that exist in the current run but have no suitable match in the previous run:
Result: added
- Completely new object
Removed Objects
Objects that existed in the previous run but have no suitable match in the current run:
Result: removed
- Object no longer exists
Key Fields vs Traditional Matching
Method | When Used | Matching Logic | Advantages |
---|---|---|---|
Key Fields | When isKeyField: true is set on monitored fields (optional) | ALL key fields must match exactly | More reliable, handles major content changes |
Traditional | When no key fields are configured (default) | >50% of fields must match | Works without configuration, good for similar objects |
Advanced Examples
Example 1: Key Field Matching with Major Changes
Result: changed
- ID key field matches despite 0% field name overlap
Example 2: Key Field Change = New Object
Result: removed
+ added
- Different ID means different objects
Example 3: Traditional Matching with High Similarity
Result: changed
- 3 out of 5 fields match = 60% > 50%
Example 4: Low Similarity = Separate Objects
Result: removed
+ added
- 0% field match, treated as separate objects
Configuration Best Practices
For Reliable Change Detection
- Key Fields (Optional): Configure
isKeyField: true
on unique identifiers for more accurate matching - Choose Stable Fields: If using key fields, select fields that rarely change (ID, URL, SKU)
- Avoid Timestamps: Don’t use frequently changing fields as key fields
- Traditional Matching Works: The default 50% field matching works well for most use cases
Good Key Field Examples
Schema Design Tips
Troubleshooting Common Issues
Objects Not Matching When They Should
Problem: Related objects treated as separate added
/removed
instead of changed
Solutions:
- Consider configuring key fields on unique identifiers for more reliable matching
- Check if key fields (if configured) are changing between runs
- Verify field names are consistent
- Ensure objects share >50% of fields for traditional matching
Objects Incorrectly Matched
Problem: Unrelated objects incorrectly matched as changed
Solutions:
- Use more specific key fields
- Ensure key fields are truly unique
- Check for data quality issues
Missing Changes
Problem: Changes not detected
Solutions:
- Verify monitored fields are configured correctly
- Check if objects are being matched at all
- Review field match ratios in logs
Integration with Monitoring
Understanding these rules helps you:
- Predict notification behavior based on your data structure
- Configure key fields for accurate change detection
- Interpret change notifications correctly
- Design robust schemas for reliable monitoring
For more information on configuring monitoring, see Real-time Monitoring Setup.