Skip to main content

Description

The Fuzzy Search Node searches through a list of strings of source data using a search pattern during the Flow execution. This Node returns the best possible matches based on a set of parameters. The Node assigns each match a score between 0 and 1, where 1 indicates the best match and 0 the worst based on the search pattern. The matches can be stored in either the Context or Input object.

Parameters

ParameterTypeDescription
Search PatternStringThe string to search for in the source data. The Fuzzy Search Node compares this pattern against each element in the array and returns the best matches. Example: Aple, Jon.
Source DataJSONA CognigyScript reference to the array that should be searched. The reference can point to the Context, Input, or Profile object. The type must be set to array. Example: { "$cs": { "script": "context.names", "type": "array" } }.
ParameterTypeDescription
Is Case SensitiveBooleanSpecify whether comparisons should be case-sensitive.
Include ScoreBooleanSpecify whether the score should be included in the result set.
Include MatchesBooleanSpecify whether the matches should be included in the result set. When active, each record in the result set includes the indices of the matched characters.
Minimum CharactersNumberOnly the matches whose length exceeds this value is returned.
Should SortBooleanSpecify whether to sort the result list by score.
ParameterTypeDescription
Find All MatchesBooleanWhen activated, the matching function continues to the end of a search pattern even if a perfect match has already been located in the string.
LocationNumberDetermine approximately where in the text the pattern is expected to be found.
ThresholdNumberAt what point does the match algorithm give up. A threshold of 1 requires a perfect match (of both letters and location), a threshold of 0.0 would match anything.
DistanceNumberDetermine how close the match must be to the fuzzy location (specified by Location).
Ignore LocationBooleanWhen activated, the search ignores Location and Distance, so it won’t matter where in the string the pattern appears.
ParameterTypeDescription
Where to store the resultListSpecify whether the result is stored in the Input or Context object.
Input Key to store ResultStringThe key to store the result in.

Example

In this example, the Fuzzy Search Node searches for the pattern Jon in an array of names stored in the Context object at context.names. The Node is configured to store the results in the Input object at input.search. The Node returns each name in the array along with a score indicating how closely it matches the search pattern.
  1. Add data to the Context object.
    {
      "names": ["John", "Jonathan", "Johnny", "Alice", "Bob"]
    }
    
  2. Specify the search pattern in the Fuzzy Search Node.
    Jon
    
  3. Specify the path for the source data in the Fuzzy Search Node.
    {
      "$cs":{
        "script":"context.names",
    
        "type":"array"
      }
    }
    
  4. Check the search results in the Input object.
    {
      "search": [
        {
          "item": "Jonathan",
          "refIndex": 1,
          "score": 0.999
        },
        {
          "item": "John",
          "refIndex": 0,
          "score": 0.6666666666666667
        },
        {
          "item": "Johnny",
          "refIndex": 2,
          "score": 0.6666666666666667
        },
        {
          "item": "Bob",
          "refIndex": 4,
          "score": 0.33333333333333337
        }
      ]
    }
    

Troubleshooting

This error occurs when the source data provided to the Fuzzy Search Node isn’t an array. The Node expects an array of strings to iterate over and calculate similarity scores.