Skip to Content

BSH Search

The BSH Search object is a powerful search system that allows you to search, filter, group, sort, and paginate data across entities in the BSH Engine. It provides a flexible and type-safe way to construct complex queries.

Properties

entity

Specifies the target entity to search within.

{ "entity": "users" }

fields

Defines which fields to retrieve from the search results.

{ "fields": ["id", "name", "email"] }

filters

Use filters to build fetch data with conditions.

{ "filters": [ { "field": "age", "operator": "gte", "value": 18 }, { "operator": "or", "filters": [ { "field": "status", "operator": "eq", "value": "active" }, { "field": "salary", "operator": "gt", "value": 50000 } ] } ] }
PropertyDescriptionRequired
operatorThe comparison or logical operator to useyes
fieldThe field to apply the condition toyes
valueThe value to compare againstyes
typeOptional type specification for the fieldno
filtersNested filters to build complex conditionsif used logical operator

groupBy

Groups results by specified fields and applies aggregate functions.

{ "groupBy": { "fields": ["department"], "aggregate": [ { "function": "COUNT", "field": "id", "alias": "total_employees" }, { "function": "AVG", "field": "salary", "alias": "avg_salary" } ] } }
PropertyDescriptionRequired
fieldsThe fields to group byno
aggregateThe aggregate functions to applyno
aggregate.functionThe aggregate function to applyyes
aggregate.fieldThe field to aggregateyes
aggregate.aliasThe alias for the aggregated resultno

sort

Defines the sorting order for the results.

{ "sort": [ { "field": "name", "direction": 1 }, { "field": "created_at", "direction": -1 } ] }
PropertyDescriptionRequired
fieldThe field to sort byyes
directionThe direction to sort by (1 for ascending, -1 for descending)yes

pagination

Controls the pagination of results.

{ "pagination": { "page": 0, "size": 20 } }
PropertyDescriptionRequiredDefault
pageThe page number (0-based)no0
sizeThe number of items per pageno10