WeaviateEx.GRPC.Services.Aggregate (WeaviateEx v0.7.4)
View SourcegRPC Aggregate service for aggregation queries.
This module provides high-level functions for performing aggregations on Weaviate collections using gRPC.
Usage
{:ok, channel} = WeaviateEx.GRPC.Channel.connect(config)
{:ok, result} = Aggregate.count(channel, "Article")
{:ok, result} = Aggregate.over_property(channel, "Article", "wordCount",
aggregations: [:sum, :mean, :minimum, :maximum]
)
Summary
Functions
Count objects in a collection.
Execute a raw AggregateRequest.
Aggregate with grouping.
Aggregate over a specific property.
Types
@type aggregate_opts() :: [ tenant: String.t(), filters: map(), group_by: String.t() | [String.t()], near_vector: [float()], near_text: String.t(), aggregations: [atom()], limit: non_neg_integer(), timeout: non_neg_integer() ]
Functions
@spec count(GRPC.Channel.t(), String.t(), aggregate_opts()) :: {:ok, struct()} | {:error, WeaviateEx.Error.t()}
Count objects in a collection.
Examples
{:ok, result} = Aggregate.count(channel, "Article")
{:ok, result} = Aggregate.count(channel, "Article", tenant: "tenant_a")
@spec execute(GRPC.Channel.t(), struct(), keyword()) :: {:ok, struct()} | {:error, WeaviateEx.Error.t()}
Execute a raw AggregateRequest.
Examples
request = %AggregateRequest{
collection: "Article",
count_by_meta: true
}
{:ok, result} = Aggregate.execute(channel, request)
@spec group_by(GRPC.Channel.t(), String.t(), String.t(), aggregate_opts()) :: {:ok, struct()} | {:error, WeaviateEx.Error.t()}
Aggregate with grouping.
Examples
{:ok, result} = Aggregate.group_by(channel, "Article", "category",
aggregations: [:count]
)
@spec over_property(GRPC.Channel.t(), String.t(), String.t(), aggregate_opts()) :: {:ok, struct()} | {:error, WeaviateEx.Error.t()}
Aggregate over a specific property.
Options
:aggregations- List of aggregation types to compute- For numbers:
:count,:sum,:mean,:median,:mode,:minimum,:maximum - For text:
:count,:top_occurrences - For boolean:
:count,:total_true,:total_false,:percentage_true,:percentage_false
- For numbers:
Examples
{:ok, result} = Aggregate.over_property(channel, "Article", "wordCount",
aggregations: [:sum, :mean, :minimum, :maximum]
)