Skip to main content

SearchVectorExact

This class provides a database lookup for performing full-text search matches between a search vector and a search query. It automatically handles the conversion of right-hand side values into search query objects and generates the SQL using the match operator. This allows for precise filtering of search vectors against specific terms or combined search expressions.

Attributes

AttributeTypeDescription
lookup_namestring = exactThe identifier used in Django ORM queries to trigger this specific full-text search comparison, set to "exact".

Methods


process_rhs()

@classmethod
def process_rhs(
qn: compiler.SQLCompiler,
connection: db.backends.base.BaseDatabaseWrapper
) - > tuple

Prepares the right-hand side of the lookup by ensuring the search term is wrapped in a SearchQuery object, inheriting the configuration from the left-hand side if necessary.

Parameters

NameTypeDescription
qncompiler.SQLCompilerThe SQL compiler instance used to quote identifiers and generate the query string.
connectiondb.backends.base.BaseDatabaseWrapperThe current database connection object used to handle backend-specific SQL generation.

Returns

TypeDescription
tupleA tuple containing the SQL string for the right-hand side and the list of parameters for the query.

as_sql()

@classmethod
def as_sql(
qn: compiler.SQLCompiler,
connection: db.backends.base.BaseDatabaseWrapper
) - > tuple

Generates the SQL fragment and parameters for the full-text search match operation using the '@@' operator.

Parameters

NameTypeDescription
qncompiler.SQLCompilerThe SQL compiler instance used to quote identifiers and generate the query string.
connectiondb.backends.base.BaseDatabaseWrapperThe current database connection object used to handle backend-specific SQL generation.

Returns

TypeDescription
tupleA tuple containing the formatted SQL string 'lhs @@ rhs' and the combined parameters from both sides.