summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorHannes Ljungberg <hannes@5monkeys.se>2020-03-20 22:01:26 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-03-23 11:00:55 +0100
commit0b51a4f8946178daf469bec4cbedbc02a23cf814 (patch)
tree11aefd7c5b20687255010004e466a5a5af1bcaae /docs/ref
parent4ed534758cb6a11df9f49baddecca5a6cdda9311 (diff)
downloaddjango-0b51a4f8946178daf469bec4cbedbc02a23cf814.tar.gz
Fixed #28194 -- Added support for normalization and cover density to SearchRank.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/contrib/postgres/search.txt28
1 files changed, 27 insertions, 1 deletions
diff --git a/docs/ref/contrib/postgres/search.txt b/docs/ref/contrib/postgres/search.txt
index 65d54cfd8d..f00bddbee4 100644
--- a/docs/ref/contrib/postgres/search.txt
+++ b/docs/ref/contrib/postgres/search.txt
@@ -118,7 +118,7 @@ See :ref:`postgresql-fts-search-configuration` for an explanation of the
``SearchRank``
==============
-.. class:: SearchRank(vector, query, weights=None)
+.. class:: SearchRank(vector, query, weights=None, normalization=None, cover_density=False)
So far, we've 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
@@ -137,6 +137,32 @@ order by relevancy::
See :ref:`postgresql-fts-weighting-queries` for an explanation of the
``weights`` parameter.
+Set the ``cover_density`` parameter to ``True`` to enable the cover density
+ranking, which means that the proximity of matching query terms is taken into
+account.
+
+Provide an integer to the ``normalization`` parameter to control rank
+normalization. This integer is a bit mask, so you can combine multiple
+behaviors::
+
+ >>> from django.db.models import Value
+ >>> Entry.objects.annotate(
+ ... rank=SearchRank(
+ ... vector,
+ ... query,
+ ... normalization=Value(2).bitor(Value(4)),
+ ... )
+ ... )
+
+The PostgreSQL documentation has more details about `different rank
+normalization options`_.
+
+.. _different rank normalization options: https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-RANKING
+
+.. versionadded:: 3.1
+
+ The ``normalization`` and ``cover_density`` parameters were added.
+
``SearchHeadline``
==================