Skip to main content

SearchLookup

This class provides a specialized lookup for full-text search operations by extending exact search vector functionality. It automatically handles the conversion of standard fields into search vectors using an optional configuration from the right-hand side of the expression. The class ensures that the left-hand side is compatible with search vector fields during query processing.

Attributes

AttributeTypeDescription
lookup_namestring = searchThe identifier used in Django querysets to perform a full-text search operation, set to "search".

Methods


process_lhs()

@classmethod
def process_lhs(
qn: django.db.models.sql.compiler.SQLCompiler,
connection: django.db.backends.base.base.BaseDatabaseWrapper
) - > tuple

Processes the left-hand side of the search lookup, ensuring the field is cast to a SearchVectorField if it is not already one.

Parameters

NameTypeDescription
qndjango.db.models.sql.compiler.SQLCompilerThe SQL compiler instance used to generate the query string.
connectiondjango.db.backends.base.base.BaseDatabaseWrapperThe current database connection used to handle backend-specific SQL generation.

Returns

TypeDescription
tupleA tuple containing the SQL string for the left-hand side and the list of parameters to be bound to the query.