summaryrefslogtreecommitdiff
path: root/docs
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
parent4ed534758cb6a11df9f49baddecca5a6cdda9311 (diff)
Fixed #28194 -- Added support for normalization and cover density to SearchRank.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/contrib/postgres/search.txt28
-rw-r--r--docs/releases/3.1.txt8
2 files changed, 35 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``
==================
diff --git a/docs/releases/3.1.txt b/docs/releases/3.1.txt
index d9c0a5db11..9961aebbab 100644
--- a/docs/releases/3.1.txt
+++ b/docs/releases/3.1.txt
@@ -160,6 +160,14 @@ Minor features
* :lookup:`search` lookup now supports query expressions.
+* The new ``cover_density`` parameter of
+ :class:`~django.contrib.postgres.search.SearchRank` allows ranking by cover
+ density.
+
+* The new ``normalization`` parameter of
+ :class:`~django.contrib.postgres.search.SearchRank` allows rank
+ normalization.
+
:mod:`django.contrib.redirects`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~