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.
Documentation
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
}
]
}
]
}Fields
| Property | Description | Required |
|---|---|---|
operator | The comparison or logical operator to use | yes |
field | The field to apply the condition to | yes |
value | The value to compare against | yes |
type | Optional type specification for the field | no |
filters | Nested filters to build complex conditions | if 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"
}
]
}
}Fields
| Property | Description | Required |
|---|---|---|
fields | The fields to group by | no |
aggregate | The aggregate functions to apply | no |
aggregate.function | The aggregate function to apply | yes |
aggregate.field | The field to aggregate | yes |
aggregate.alias | The alias for the aggregated result | no |
sort
Defines the sorting order for the results.
{
"sort": [
{
"field": "name",
"direction": 1
},
{
"field": "created_at",
"direction": -1
}
]
}| Property | Description | Required |
|---|---|---|
field | The field to sort by | yes |
direction | The direction to sort by (1 for ascending, -1 for descending) | yes |
pagination
Controls the pagination of results.
{
"pagination": {
"page": 0,
"size": 20
}
}| Property | Description | Required | Default |
|---|---|---|---|
page | The page number (0-based) | no | 0 |
size | The number of items per page | no | 10 |