mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #33788 -- Added TrigramStrictWordSimilarity() and TrigramStrictWordDistance() on PostgreSQL.
This commit is contained in:
parent
3ef37a5245
commit
8d160f154f
8 changed files with 130 additions and 5 deletions
|
@ -286,9 +286,9 @@ Trigram similarity
|
|||
==================
|
||||
|
||||
Another approach to searching is trigram similarity. A trigram is a group of
|
||||
three consecutive characters. In addition to the :lookup:`trigram_similar` and
|
||||
:lookup:`trigram_word_similar` lookups, you can use a couple of other
|
||||
expressions.
|
||||
three consecutive characters. In addition to the :lookup:`trigram_similar`,
|
||||
:lookup:`trigram_word_similar`, and :lookup:`trigram_strict_word_similar`
|
||||
lookups, you can use a couple of other expressions.
|
||||
|
||||
To use them, you need to activate the `pg_trgm extension
|
||||
<https://www.postgresql.org/docs/current/pgtrgm.html>`_ on PostgreSQL. You can
|
||||
|
@ -334,6 +334,18 @@ Usage example::
|
|||
... ).filter(similarity__gt=0.3).order_by('-similarity')
|
||||
[<Author: Katy Stevens>]
|
||||
|
||||
``TrigramStrictWordSimilarity``
|
||||
-------------------------------
|
||||
|
||||
.. class:: TrigramStrictWordSimilarity(string, expression, **extra)
|
||||
|
||||
.. versionadded:: 4.2
|
||||
|
||||
Accepts a string or expression, and a field name or expression. Returns the
|
||||
trigram strict word similarity between the two arguments. Similar to
|
||||
:class:`TrigramWordSimilarity() <TrigramWordSimilarity>`, except that it forces
|
||||
extent boundaries to match word boundaries.
|
||||
|
||||
``TrigramDistance``
|
||||
-------------------
|
||||
|
||||
|
@ -371,3 +383,13 @@ Usage example::
|
|||
... distance=TrigramWordDistance(test, 'name'),
|
||||
... ).filter(distance__lte=0.7).order_by('distance')
|
||||
[<Author: Katy Stevens>]
|
||||
|
||||
``TrigramStrictWordDistance``
|
||||
-----------------------------
|
||||
|
||||
.. class:: TrigramStrictWordDistance(string, expression, **extra)
|
||||
|
||||
.. versionadded:: 4.2
|
||||
|
||||
Accepts a string or expression, and a field name or expression. Returns the
|
||||
trigram strict word distance between the two arguments.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue