summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/contrib/postgres/search.txt21
1 files changed, 20 insertions, 1 deletions
diff --git a/docs/ref/contrib/postgres/search.txt b/docs/ref/contrib/postgres/search.txt
index 815b423c35..1ae6233abe 100644
--- a/docs/ref/contrib/postgres/search.txt
+++ b/docs/ref/contrib/postgres/search.txt
@@ -70,13 +70,28 @@ and ``weight`` parameters.
``SearchQuery``
===============
-.. class:: SearchQuery(value, config=None)
+.. class:: SearchQuery(value, config=None, search_type='plain')
``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.
+If ``search_type`` is ``'plain'``, which is the default, the terms are treated
+as separate keywords. If ``search_type`` is ``'phrase'``, the terms are treated
+as a single phrase. If ``search_type`` is ``'raw'``, then you can provide a
+formatted search query with terms and operators. Read PostgreSQL's `Full Text
+Search docs`_ to learn about differences and syntax. Examples:
+
+.. _Full Text Search docs: https://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES
+
+ >>> from django.contrib.postgres.search import SearchQuery
+ >>> SearchQuery('red tomato') # two keywords
+ >>> SearchQuery('tomato red') # same results as above
+ >>> SearchQuery('red tomato', search_type='phrase') # a phrase
+ >>> SearchQuery('tomato red', search_type='phrase') # a different phrase
+ >>> SearchQuery("'tomato' & ('red' | 'green')", search_type='raw') # boolean operators
+
``SearchQuery`` terms can be combined logically to provide more flexibility::
>>> from django.contrib.postgres.search import SearchQuery
@@ -87,6 +102,10 @@ looks for matches for all of the resulting terms.
See :ref:`postgresql-fts-search-configuration` for an explanation of the
``config`` parameter.
+.. versionadded:: 2.2
+
+ The `search_type` parameter was added.
+
``SearchRank``
==============