summaryrefslogtreecommitdiff
path: root/docs/ref/contrib/postgres/lookups.txt
diff options
context:
space:
mode:
Diffstat (limited to 'docs/ref/contrib/postgres/lookups.txt')
-rw-r--r--docs/ref/contrib/postgres/lookups.txt26
1 files changed, 26 insertions, 0 deletions
diff --git a/docs/ref/contrib/postgres/lookups.txt b/docs/ref/contrib/postgres/lookups.txt
index 1f0af07b0d..daf784e221 100644
--- a/docs/ref/contrib/postgres/lookups.txt
+++ b/docs/ref/contrib/postgres/lookups.txt
@@ -2,6 +2,32 @@
PostgreSQL specific lookups
===========================
+Trigram similarity
+==================
+
+.. fieldlookup:: trigram_similar
+
+.. versionadded:: 1.10
+
+The ``trigram_similar`` lookup allows you to perform trigram lookups,
+measuring the number of trigrams (three consecutive characters) shared, using a
+dedicated PostgreSQL extension. A trigram lookup is given an expression and
+returns results that have a similarity measurement greater than the current
+similarity threshold.
+
+To use it, add ``'django.contrib.postgres'`` in your :setting:`INSTALLED_APPS`
+and activate the `pg_trgm extension
+<http://www.postgresql.org/docs/current/interactive/pgtrgm.html>`_ on
+PostgreSQL. You can install the extension using the
+:class:`~django.contrib.postgres.operations.TrigramExtension` migration
+operation.
+
+The ``trigram_similar`` lookup can be used on
+:class:`~django.db.models.CharField` and :class:`~django.db.models.TextField`::
+
+ >>> City.objects.filter(name__trigram_similar="Middlesborough")
+ ['<City: Middlesbrough>']
+
``Unaccent``
============