The docs on the word_similarity function say:
Returns a number that indicates how similar the first string to the most similar word of the second string. The function searches in the second string a most similar word not a most similar substring. The range of the result is zero (indicating that the two strings are completely dissimilar) to one (indicating that the first string is identical to one of the words of the second string).
But they are a bit vague about what the result should be if the 'first string' contains more than one word. What is the explanation for the following results:
select word_similarity('foo bar','foo bar baz');| word_similarity | | :-------------- | | 1 |
select word_similarity('baz bar','foo bar baz');| word_similarity | | :-------------- | | 1 |
select word_similarity('baz foo','foo bar baz');| word_similarity | | :-------------- | | 0.8 |
dbfiddle here