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') & SearchQuery('ireland')  # potato AND ireland
>>> SearchQuery('potato') | SearchQuery('penguin')  # potato OR penguin
>>> ~SearchQuery('sausage')  # NOT sausage

See Changing the search configuration for an explanation of the config parameter.

doc_Django
2016-10-09 18:39:23
Comments
Leave a Comment

Please login to continue.