word_keys_diff() function

The word_keys_diff() function computes the lexical difference between phonetic encodings that the word_key() function produces.

You can compare Soundex word keys for an exact match by comparing the int4 keys directly, without using this function.

Syntax

The word_keys_diff() function has the following syntax:
int1 = word_keys_diff(int4 wordkey1, int4 wordkey2 [, int1 
algorithm]));

The wordkey1 value specifies the first word_key() function encoding in the comparison.

The wordkey2 value specifies the second word_key() function encoding in the comparison.

The algorithm value is one of the following values:
0
Soundex-Miracode.
1
Soundex-Simplified.
2
Soundex-SQLServer.
3
Double Metaphone. This is the default.

Returns

The word_keys_diff function returns the Soundex values of 0 - 4, where 0 represents an exact match and 1 - 4 represent increasing degrees of inexactness.

Example

The following example returns 1 because the two Soundex encodings differ by one character: the Soundex code for Johnson is J525, and the Soundex code for Jeppeson is J125.
select word_keys_diff(word_key('Johnson',0),word_key('Jeppeson',0),0);
 WORD_KEYS_DIFF
----------------
             1
(1 row)