Skip to main content

TrigramBase

This class serves as a base for trigram-based database functions, calculating the similarity or distance between a field expression and a provided string. It automatically handles the conversion of raw string inputs into value expressions and ensures the result is returned as a floating-point field.

Attributes

AttributeTypeDescription
output_field[FloatField](../../../forms/fields/floatfield.md?sid=django_forms_fields_floatfield) = FloatField()Defines the database type for the result of the trigram operation, defaulting to a FloatField to represent similarity scores or distances.

Constructor

Signature

def TrigramBase(
expression: Any,
string: Any,
**extra: dict
)

Parameters

NameTypeDescription
expressionAnyThe field or expression to be evaluated.
stringAnyThe string to compare against the expression.
**extradictAdditional keyword arguments for the function.

Signature

def TrigramBase(
expression: [Expression](../../../db/models/expressions/expression.md?sid=django_db_models_expressions_expression),
string: str|Expression,
**extra: dict
) - > null

Parameters

NameTypeDescription
expression[Expression](../../../db/models/expressions/expression.md?sid=django_db_models_expressions_expression)The database column or expression to be compared.
string`strExpression`
**extradictAdditional keyword arguments for configuring the underlying database function, such as output_field or filter.