Python django.contrib.postgres.search.SearchVectorField() Examples
The following are 1
code examples of django.contrib.postgres.search.SearchVectorField().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.contrib.postgres.search
, or try the search function
.
Example #1
Source File: models.py From lexpredict-contraxsuite with GNU Affero General Public License v3.0 | 6 votes |
def as_postgresql(self, qn, connection): source_field = self.lhs.field model = source_field.model tsv_column_name = source_field.name + self.tsvector_column_suffix model_fields = {i.name: i for i in model._meta.fields} tsv_field = model_fields.get(tsv_column_name) if tsv_field is None or not isinstance(tsv_field, SearchVectorField): # raise RuntimeError('Model "{}" should have "{}" field.'.format(model, tsv_column_name)) # fail silently - use insensitive contains search return IContains(self.lhs, self.rhs).as_sql(qn, connection) if source_field.name not in getattr(self.lhs.field.model, 'full_text_search_fields', []): # raise RuntimeError('Model "{}" should have "{}" in "{}" class atribute (List).'.format( # model, 'full_text_search_fields', tsv_column_name)) # fail silently - use insensitive contains search return IContains(self.lhs, self.rhs).as_sql(qn, connection) return self.get_fts_lookup(qn, connection)