CodamAIDocs
Topicdone

Filters in nested lists

When a parameter goes at the top level and when inside a response entry, and what this means for the amount of data.

Variants
filter on the matchesfilter on a sublistboth togethersublist without limit

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
  }
}
Top level or inside?
parameter at the top level
next to response
  • decides which companies are matches
  • here: companies from Köln, 25 per page
  • returns meta with totalCount
parameter inside
in the response entry employees
  • 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

What do you want?
QuestionWhere does the filter go?
Companies that have an employee named Meiertop level, as the path employees.lastname or with MEMBEROF
All companies, each with only its employees named Meierinside, in the parameter of the entry employees
Companies with a Meier, and for each one only the Meierstop 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”

How many employees come back?

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

SettinginsideNote
queryyesis attached with AND to the link to the company
orderyesorder of the list
limityesper company
pageyesper company, rarely useful
metanothe 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.

Sources in the code and the knowledge base
  • CDMS/cdms-system-layer – AbstractLayer.recursiveQuery, fetchAndSetList
  • Probe against cdms-integrationtest (company, employee), 2026-09-21
Search