OriginChainDB
Database endpoints

Aggregate text results

Summarize stored document values across matching full-text results or the whole field.

POST /v1/tenants/{tenant}/fts/{table}/_aggs

Summarize values from matching documentsStore facet values first; indexing words alone is not enough.
  1. Choose the document setUse a text search or the whole field.
  2. Aggregate stored valuesGroup or summarize the requested facets.
  3. Read counts and summariesCompare doc_count with the named aggregation results.

Before you start

Use your database bearer token.

Connection setup

Store facet values with Store original text before aggregating them. The example uses category facets.

Path parameters

FieldTypeRequired
tenantstringRequired
tablestringRequired

Headers

FieldTypeRequiredDescription
x-oc-db-userstringOptionalActing database user (role, grant and row-policy checks). Send with x-oc-db-key.
x-oc-db-keystringOptionalAPI key of the x-oc-db-user user.

Request body

application/json

Limits and accepted values
  • field names the full-text field whose per-document values (written via the doc endpoint) are aggregated.
  • aggs must be non-empty (400 otherwise).
  • filter_expr is accepted only to be refused: any non-null value, top-level or inside search, answers 501.
FieldTypeRequiredDescription
aggsobjectOptionalMap of aggregation name -> aggregation node. A node is {"<kind>": {...}, "aggs": {<children>}}. Bucket kinds: terms, range, histogram, date_histogram, filter, filters, missing, global. Metric kinds: count, min, max, sum, avg, stats, extended_stats, cardinality, percentiles, percentile_ranks, top_hits. Pipeline kinds: bucket_sort, cumulative_sum, derivative, serial_diff, moving_fn, bucket_script, bucket_selector, avg_bucket, sum_bucket, min_bucket, max_bucket, stats_bucket. Fields are named with "field".
fieldstringRequired—
searchobjectOptionalA _search request body selecting the documents to aggregate (doc_values_field is refused here). Absent means match_all over field.
Fields in search
FieldTypeRequiredDescription
default_fieldstringOptional—
exact_totalbooleanOptional—
min_scorenumberOptional—
paramsobjectOptionalBM25 tunables; both optional.
Fields in params
FieldTypeRequired
bnumberOptional
k1numberOptional
FieldTypeRequiredDescription
queryany JSONRequired—
search_afterobjectOptionalvalues holds one JSON scalar per sort key (any scalar type; null means missing) and must match the sort length. doc_id is the tiebreak of the last hit seen.
Fields in search_after
FieldTypeRequired
doc_idstringOptional
valuesany JSON[]Required
Fields in values
FieldTypeRequired
valuesany JSONOptional
FieldTypeRequired
sortobject[]Optional
Fields in sort
FieldTypeRequired
ascendingbooleanRequired
fieldstringRequired
missingany JSONOptional
modestringOptional
rolestringRequired
truncatebooleanOptional
FieldTypeRequired
tablestringOptional
top_kintegerOptional
total_ceilingintegerOptional
unindexed_fields_are_emptybooleanOptional
universe_fieldstringOptional

Read the result

Read doc_count alongside the named results in aggs. Bucket counts group stored facet values, so you must store those values before aggregating them; indexing words alone is not enough.

Response statuses

HTTP status reference
StatusWhat to do
200OK
400Correct the request before retrying.
401Check the credential and Authorization header.
402Check feature access or available credits.
403Check tenant access, roles and permissions.
404Check the resource ID and API route.
408Reduce query work or adjust the timeout.
413Split or reduce the request body.
415Send the required Content-Type.
422Correct the values or unsupported combination.
429Honor Retry-After when present; back off.
499The client cancelled the request.
500Check the outcome before retrying a write.
501Check deployment support for this operation.
503Honor Retry-After when present; check write outcomes.
© 2026 Silicoyn Technologies Pvt Ltd