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.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.operations.UnaccentExtension

class UnaccentExtension [source] Installs the unaccent extension.

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.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.TrigramSimilarity

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

postgres.forms.SplitArrayField.size

size This is the fixed number of times the underlying field will be used.

postgres.functions.TransactionNow

class TransactionNow [source] New in Django 1.9. Returns the date and time on the database server that the current transaction started. If you are not in a transaction it will return the date and time of the current statement. This is a complement to django.db.models.functions.Now, which returns the date and time of the current statement. Note that only the outermost call to atomic() sets up a transaction and thus sets the time that TransactionNow() will return; nested calls create savepoi

postgres.forms.SplitArrayField.remove_trailing_nulls

remove_trailing_nulls By default, this is set to False. When False, each value from the repeated fields is stored. When set to True, any trailing values which are blank will be stripped from the result. If the underlying field has required=True, but remove_trailing_nulls is True, then null values are only allowed at the end, and will be stripped. Some examples: SplitArrayField(IntegerField(required=True), size=3, remove_trailing_nulls=False) ['1', '2', '3'] # -> [1, 2, 3] ['1', '2', '']

postgres.operations.TrigramExtension

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