Classes
LogicalExpr
Internal Instances of theLogicalExpr class are used to represent logical expressions in TopK.
Usually created using logical constructors such as field(), literal(), etc.
Methods
is_null()
LogicalExpr
is_not_null()
LogicalExpr
abs()
LogicalExpr
ln()
LogicalExpr
exp()
LogicalExpr
sqrt()
LogicalExpr
square()
LogicalExpr
eq()
Returns
LogicalExpr
ne()
Returns
LogicalExpr
lt()
Returns
LogicalExpr
lte()
Returns
LogicalExpr
gt()
Returns
LogicalExpr
gte()
Returns
LogicalExpr
add()
Returns
LogicalExpr
sub()
Returns
LogicalExpr
mul()
Returns
LogicalExpr
div()
Returns
LogicalExpr
min()
Returns
LogicalExpr
max()
Returns
LogicalExpr
and_()
Returns
LogicalExpr
or_()
Returns
LogicalExpr
starts_with()
Returns
LogicalExpr
contains()
Returns
LogicalExpr
in_()
Returns
LogicalExpr
match_all()
Returns
LogicalExpr
match_any()
Returns
LogicalExpr
coalesce()
Returns
LogicalExpr
choose()
Returns
LogicalExpr
boost()
boost value if the condition is true.
Parameters
Returns
LogicalExpr
regexp_match()
Returns
LogicalExpr
FunctionExpr
Internal Instances of theFunctionExpr class are used to represent function expressions in TopK.
Usually created using function constructors such as fn.vector_distance(), fn.semantic_similarity() or fn.bm25_score().
AggregateExpr
Internal Instances of theAggregateExpr class are used to represent aggregate expressions in TopK.
Usually created using aggregate constructors such as agg.count(), agg.sum(), agg.min(), agg.max() or agg.avg().
TextExpr
Internal Instances of theTextExpr class are used to represent text expressions in TopK.
Query
Methodsselect()
Query
filter()
Returns
Query
sort()
Returns
Query
limit()
Returns
Query
offset()
Returns
Query
count()
Query
group_by()
Returns
Query
topk()
Returns
Query
fn
Thequery.fn submodule exposes functions for creating function expressions such as fn.vector_distance(), fn.semantic_similarity() or fn.bm25_score().
Methods
vector_distance()
Returns
FunctionExpr
semantic_similarity()
Returns
FunctionExpr
bm25_score()
Returns
FunctionExpr
multi_vector_distance()
Matrix instance. To specify a different matrix type,
use matrix() with value_type or a 2-D numpy array with the
corresponding dtype.
The optional candidates parameter limits the number of candidate vectors considered during search.
Returns
FunctionExpr
agg
Thequery.agg submodule exposes functions for creating aggregate expressions used in
group_by()’s aggs argument, such as agg.count(), agg.sum(),
agg.min(), agg.max() or agg.avg().
Methods
count()
field is provided, counts only the documents where that field is non-null.
If omitted, counts every document in the group.
Returns
AggregateExpr
sum()
field across the group.
Parameters
Returns
AggregateExpr
min()
field across the group.
Parameters
Returns
AggregateExpr
max()
field across the group.
Parameters
Returns
AggregateExpr
avg()
field across the group.
Parameters
Returns
AggregateExpr
Functions
field()
Returns
LogicalExpr
select()
Query
filter()
Returns
Query
group_by()
Returns
Query
literal()
Returns
LogicalExpr
match()
token argument is a raw query string — TopK tokenizes it automatically,
removes stop words, and scores documents using BM25. Pass the full query string
directly; tokenization and stop-word removal happen server-side.
field: restrict matching to a specific keyword-indexed field (default: all).weight: scale the BM25 contribution of this expression (default: 1.0).all: if True, require all tokens to match (AND); default is any-token (OR).
Returns
TextExpr
match_tokens()
field is provided, matches only against that field (must have a keyword index).
When field is None (default), matches against all keyword-indexed fields.
When all is False (default), matches documents containing any of the tokens (OR).
When all is True, matches only documents containing all tokens (AND).
Parameters
Returns
TextExpr
not_()
Returns
LogicalExpr
abs()
Returns
LogicalExpr
all()
Returns
LogicalExpr
any()
Returns
LogicalExpr
min()
Returns
LogicalExpr
max()
Returns
LogicalExpr
Type Aliases
FlexibleExpr
LogicalExpr
Numeric
LogicalExpr
Ordered
LogicalExpr
Boolish
LogicalExpr
Stringy
LogicalExpr
StringyWithList
LogicalExpr
Iterable
topk_sdk.data.List | LogicalExpr