postgres.search.TrigramDistance

class TrigramDistance(expression, string, **extra) [source] New in Django 1.10. Accepts a field name or expression, and a string or expression. Returns the trigram distance between the two arguments. Usage example: >>> from django.contrib.postgres.search import TrigramDistance >>> Author.objects.create(name='Katy Stevens') >>> Author.objects.create(name='Stephen Keats') >>> test = 'Katie Stephens' >>> Author.objects.annotate( ... distance=Tr

postgres.search.SearchVectorField

class SearchVectorField [source] If this approach becomes too slow, you can add a SearchVectorField to your model. You’ll need to keep it populated with triggers, for example, as described in the PostgreSQL documentation. You can then query the field as if it were an annotated SearchVector: >>> Entry.objects.update(search_vector=SearchVector('body_text')) >>> Entry.objects.filter(search_vector='cheese') [<Entry: Cheese on Toast recipes>, <Entry: Pizza recipes>]

postgres.search.SearchVector

class SearchVector(*expressions, config=None, weight=None) [source] Searching against a single field is great but rather limiting. The Entry instances we’re searching belong to a Blog, which has a tagline field. To query against both fields, use a SearchVector: >>> from django.contrib.postgres.search import SearchVector >>> Entry.objects.annotate( ... search=SearchVector('body_text', 'blog__tagline'), ... ).filter(search='Cheese') [<Entry: Cheese on Toast recipes>

postgres.search.SearchRank

class SearchRank(vector, query, weights=None) [source] So far, we’ve just returned the results for which any match between the vector and the query are possible. It’s likely you may wish to order the results by some sort of relevancy. PostgreSQL provides a ranking function which takes into account how often the query terms appear in the document, how close together the terms are in the document, and how important the part of the document is where they occur. The better the match, the higher

postgres.search.SearchQuery

class SearchQuery(value, config=None) [source] SearchQuery translates the terms the user provides into a search query object that the database compares to a search vector. By default, all the words the user provides are passed through the stemming algorithms, and then it looks for matches for all of the resulting terms. SearchQuery terms can be combined logically to provide more flexibility: >>> from django.contrib.postgres.search import SearchQuery >>> SearchQuery('potato'

postgres.operations.UnaccentExtension

class UnaccentExtension [source] Installs the unaccent extension.

postgres.operations.TrigramExtension

class TrigramExtension [source] New in Django 1.10. Installs the pg_trgm extension.

postgres.operations.HStoreExtension

class HStoreExtension [source] Installs the hstore extension and also sets up the connection to interpret hstore data for possible use in subsequent migrations.

postgres.operations.CreateExtension.name

name This is a required argument. The name of the extension to be installed.

postgres.operations.CreateExtension

class CreateExtension(name) [source] An Operation subclass which installs PostgreSQL extensions. name This is a required argument. The name of the extension to be installed.