mirror of
https://github.com/django/django.git
synced 2025-07-14 16:55:17 +00:00
Fixed #28194 -- Added support for normalization and cover density to SearchRank.
This commit is contained in:
parent
4ed534758c
commit
0b51a4f894
4 changed files with 106 additions and 3 deletions
|
@ -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``
|
||||
==================
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue