QBVectorColumn
Overview
The QBVectorColumn class represents a vector column in a QBSelect query.
For more information about constructing and executing queries and columns, refer to the QBSelect section of this documentation.
Extends
Properties Summarized
Methods Summarized
Calculate the database native cosine distance for this column using the embedding.
Calculate the normalized score for this column using the embedding.
Properties Detailed
isNull
Compare column with null.
Type QBCondition a QBCondition representing the "is null" comparison.
Sample
max
Create an aggregate max expression.
Type QBVectorColumn a QBColumn representing the sum aggregate function.
Sample
min
Create an aggregate min expression.
Type QBVectorColumn a QBColumn representing the minimum aggregate function.
Sample
not
Create a negated condition.
Type QBColumnComparable a QBColumn representing the negated condition.
Sample
Methods Detailed
between(value1, value2)
Compare column to a range of 2 values or other columns.
Parameters
Returns: QBCondition a QBCondition representing the "between" comparison for the two values.
Sample
coalesce(value)
Create coalesce(arg) expression
Parameters
Object value when column is null
Returns: QBVectorColumn a QBColumn representing the coalesce expression.
Sample
eq(value)
Compare column with a value or another column. Operator: equals
Parameters
Object value ;
Returns: QBCondition a QBCondition representing the "equals" comparison.
Sample
ge(value)
Compare column with a value or another column. Operator: greaterThanOrEqual
Parameters
Object value ;
Returns: QBCondition a QBCondition representing the "greater than or equal to" comparison.
Sample
gt(value)
Compare column with a value or another column. Operator: greaterThan
Parameters
Object value ;
Returns: QBCondition a QBCondition representing the "greater than" comparison.
Sample
isin(query)
Compare column with subquery result.
Parameters
QBPart query subquery
Returns: QBCondition a QBCondition representing the "in" comparison with a subquery.
Sample
isin(values)
Compare column with values.
Parameters
Array values array of values
Returns: QBCondition a QBCondition representing the "in" comparison with a list of values.
Sample
isin(customQuery, args)
Compare column with custom query result.
Parameters
Returns: QBCondition a QBCondition representing the "in" comparison with a custom query and arguments.
Sample
le(value)
Compare column with a value or another column. Operator: lessThanOrEqual
Parameters
Object value ;
Returns: QBCondition a QBCondition representing the "less than or equal to" comparison.
Sample
lt(value)
Compare column with a value or another column. Operator: lessThan
Parameters
Object value ;
Returns: QBCondition a QBCondition representing the "less than" comparison.
Sample
nullif(arg)
Create nullif(arg) expression
Parameters
Object arg object to compare
Returns: QBVectorColumn a QBColumn representing the nullif expression.
Sample
vector_distance(embedding)
Calculate the database native cosine distance for this column using the embedding.
The native cosine distance is a positive number where lower means better. When sorting on score you can sort on 'vector_distance(embedding) asc' to get the best matches first.
Parameters
Array embedding embedding object
Returns: QBNumberColumn the QBNumberColumn that can be used for sorting.
Sample
vector_score(embedding)
Calculate the normalized score for this column using the embedding.
The normalized score is a number from 0 to 1 where higher means better. When sorting on score you can sort on 'vector_score(embedding) desc' to get the best matches first. It is more efficient to sort using the native distance function 'vector_distance(embedding) asc' to get the best matches first.
The score result has a function min_score for filtering on the score, this is optimized for filtering compared to the standard number comparison functions.
Parameters
Array embedding embedding object
Returns: QBScoreColumn the QBScoreColumn that can be added to the result.
Sample
Last updated
Was this helpful?