#31304: PostgreSQL full-text search employs coalesce function for non-null
single-
column searches with SearchVector
-------------------------------------+-------------------------------------
Reporter: Paul Boddie | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: PostgreSQL text | Triage Stage: Accepted
search FTS coalesce SearchVector |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
Until this is addressed, assuming you know expressions you are dealing
with are `NOT NULL`, a limited replacement for `SearchVector` is the
following
{{{#!python
from django.contrib.postgres.search import SearchConfig, SearchVectorField
from django.db.models import Func
from django.db.models.expressions import ExpressionList
class SearchVector(Func):
"""
Replacement of `django.contrib.postgres.search.SearchVector` that
works around limitations of the later with regards to indexing.
See https://code.djangoproject.com/ticket/31304#comment:6
"""
function = 'to_tsvector'
output_field = SearchVectorField()
def __init__(self, *expressions, config=None):
expressions = (
SearchConfig.from_parameter(config),
ExpressionList(*expressions, arg_joiner=" || ' ' || "),
)
super().__init__(*expressions)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31304#comment:14>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.56f485576a69c7961ab071492b5136b3%40djangoproject.com.