I was reading up on materialized views in the PostgreSQL 9.3 documentation and came across the following example, which is given in reference to spell checking a word:
SELECT word FROM words ORDER BY word <-> 'caterpiler' LIMIT 10;
I've tried searching Google and StackOverflow, but punctuation gets filtered out and I cannot see to come up what it is referring to. Can someone explain how and what it is used for?
And maybe a link to the documentation where I can read up more on the details of its usage?
According to http://www.postgresql.org/docs/9.1/static/pgtrgm.html this operator <->
returns edit distance between strings
text <-> text real Returns the "distance" between the arguments, that is one minus the similarity() value.
So the whole query looks for the 10 most similar words to the word "caterpiler" in terms of edit distance
That's the operator for finding the distance between two geometric figures (see the documentation). Also, it's the "distance" (Levenshtein's? the documentation does not state this explicitly) between strings according to this:
text <-> text
Returns the "distance" between the arguments, that is one minus the similarity() value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With