What this is about
In a search, a parameter can be in two places. Both look the same, but they affect completely different things:
{
"response": [
"companyname",
{
"field": "employees",
"response": ["firstname"],
"parameter": { "limit": 5, "order": [{ "field": "firstname", "order": "ASC" }] }
}
],
"parameter": {
"query": { "type": "AND", "filter": [{ "key": "city", "value": "Köln", "param": "EQ" }] },
"limit": 25
}
}
- decides which companies are matches
- here: companies from Köln, 25 per page
- returns
metawithtotalCount
- decides which employees are in the list of each company
- here: the first 5 by first name
- removes no company from the matches
- no own
meta
Keep the two questions apart
| Question | Where does the filter go? |
|---|---|
| Companies that have an employee named Meier | top level, as the path employees.lastname or with MEMBEROF |
| All companies, each with only its employees named Meier | inside, in the parameter of the entry employees |
| Companies with a Meier, and for each one only the Meiers | top level and inside, the same filter in both places |
Filters at the top level across a list: see Filtering and sorting across relations and Searching collections with MEMBEROF.
How CDMS runs this
sequenceDiagram
participant C as Client
participant D as CDMS
participant DB as Database
C->>D: POST /company/query
D->>DB: companies with the top-level parameter (Köln, limit 25)
DB-->>D: 25 companies
loop for each company
D->>DB: employees with company.id = … AND the inner parameter
DB-->>D: up to 5 employees
end
D-->>C: 25 companies, each with its list
CDMS adds the filter company.id = … for the current company itself. More on the flow in Expanding references and lists.
The calculation “25 × 500”
When: "parameter": { "limit": 5 } in the entry employees, limit 25 at the top level
25 companies × at most 5 employees.
Result: at most 125 employees.
When: no parameter in the entry, each company has 500 employees
25 companies × 500 employees, all with the requested fields.
Result: 12,500 employees in one response.
When: no limit at the top level, 2,000 companies, no limit inside
2,000 companies × 500 employees.
Result: 1,000,000 employees. The response becomes very slow or fails.
What the inner parameter can do
| Setting | inside | Note |
|---|---|---|
query | yes | is attached with AND to the link to the company |
order | yes | order of the list |
limit | yes | per company |
page | yes | per company, rarely useful |
meta | no | the list is a plain array without totalCount |
If you need the number of employees of a company, ask POST /employee/query directly with company.id = … and limit: 0, see Paging and match count.