﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32492	Add django API for Postgres pg_trgm word_similarity, fuzzy full-text search.	Taneli	Nikita Marchant	"Use case: filter queryset by an inexact substring. For example, retrieve an object with the following headline ''Dogecoin is following bitcoin in its dramatic rise'' when searching for ''dogge''.
 
Currently it is possible to filter a queryset on the basis of trigram similarity between the search string and full text stored in a column. 
 {{{#!python
Author.objects.annotate(similarity=TrigramSimilarity('name', test),).filter(similarity__gt=0.3)
}}}

This is a wrapper around the '''similarity''' function of the '''pg_trgm''' extension. While it allows comparing full strings, i.e. searching for 'doge'  would find 'dogs' or 'dogge' it is useless for fuzzy searching of substrings.

{{{
SELECT similarity('dogge', 'doge');
---------
0.57

SELECT similarity('dogge', 'dogecoin is following bitcoin');
------------
0.1
}}}

'''word_similarity''' does take into account the word boundaries

{{{
SELECT word_similarity('doge', 'dogecoin is following bitcoin');
--------------
0.5
}}}

Adding a django API to '''word_similarity''' would allow for better fuzzy fulltext search without a need to use either raw SQL or external tools like elasticsearch.

"	New feature	closed	contrib.postgres	dev	Normal	fixed		Paolo Melchiorre	Ready for checkin	1	0	0	0	0	0
