--- title: "Sub search" slug: "core-sub-search" updated: 2026-05-19T11:52:40Z published: 2026-05-19T11:52:40Z canonical: "docs.lobstersoftware.com/core-sub-search" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt > Use this file to discover all available pages before exploring further. # Sub search > [!NOTE] > Restrictions – Abstract > > **Purpose:** As a restriction, a [Sub search](/v1/docs/en/core-sub-search) checks whether at least one instance exists for the selected **Entity** that fulfills the configured **Where** condition. > > > [!TIP] > > Tooltip > > > > - **Usage**: In certain cases, the [Simple property restriction](/v1/docs/en/core-simple-property-search) can be configured with the same effect instead of a [Field restriction](/v1/docs/en/core-property-search). The main advantage here is the simpler "inner" structure, which can be created or adapted more easily in the automation context if necessary. > > - **Parameter**: The following parameters define a *child* search that is executed on the database side as an EXISTS condition. > > - It is generally not necessary to configure a **Projection**. On the database side, the static value 1 is used as the projection if necessary. > > - If required, the *child* search can be extended by one or more **Joins**. > > - A **Group by** for the results of the *child* search does not usually represent any added value, as the only decisive factor for the restriction is whether there is at least one match or none. > > - **Note**: The [Sub search](/v1/docs/en/core-sub-search) ignores access restrictions. It considers all instances of the selected **Entity** regardless of ownership, participation or [Company authorizations](/v1/docs/en/base-company-release). ![images/download/attachments/162410478/image-2024-1-3_10-18-39-version-1-modificationdate-1704273519209-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2024-1-3_10-18-39-version-1-modificationdate-1704273519209-api-v2.png) As a *restriction*, a [Sub search](/v1/docs/en/core-sub-search) checks whether at least one instance exists for the selected **Entity** that fulfills the configured **Where** condition. - In the same way as the [Subsearch projection](/v1/docs/en/core-sub-select-projection), a [Tuple search](/v1/docs/en/core-tuple-search) can be formally configured with a *single* **Projection**, which can also contain **Joins** and criteria for a **Group by**. - [Projections](/v1/docs/en/core-i-search-projection) within the [Sub search](/v1/docs/en/core-sub-search) primarily refer to the **Entity** selected for the [Sub search](/v1/docs/en/core-sub-search) as the data source. - The `_parentQuery` prefix enables references to the parent search. It can be cascaded if required (`_parentQuery._parentQuery.[...]`) to address a specific level of a multi-level hierarchy. - In contrast to a [Subsearch projection](/v1/docs/en/core-sub-select-projection), however, the [Sub search](/v1/docs/en/core-sub-search), like all other [Restrictions](/v1/docs/en/core-i-search-restriction), only returns a Boolean return value and does not provide any details about the search result or the value of any configured **Projection**: - The return value is `true` if at least one instance exists for the **Entity** that fulfills the **Where** condition. - The return value is `false` if no instance exists for the **Entity** that fulfills the **Where** condition. --- **IMPORTANT:** The [Sub search](/v1/docs/en/core-sub-search) ignores access restrictions. It considers all instances of the selected **Entity** regardless of ownership, participation or [Company authorizations](/v1/docs/en/base-company-release). --- ## Configuration | Parameter | Type | Description | | --- | --- | --- | | **Entity** | *Entity type* | The selection for the **Entity** parameter determines the primary data source for the [Sub search](/v1/docs/en/core-sub-search). Only the entity types offered in the *dropdown* can be selected. *Entity types* that are not directly available as an 'Entity' in the *parent* search (e.g. attributes) can also be selected for a [Sub search](/v1/docs/en/core-sub-search). **NOTE:** Additional data sources can optionally be integrated into the [Sub search](/v1/docs/en/core-sub-search) via **Joins**. | | **Projection** | *Projection* | The configuration of a **Projection** can be dispensed with, as only the existence of a 'result line" is decisive for the [Sub search](/v1/docs/en/core-sub-search) as a restriction. - If no **Projection** is defined, the [Sub search](/v1/docs/en/core-sub-search) is implemented in the database (in the `EXISTS` condition) with the static `Long` value `1` as the only projection. | | **Joins** | *Join* | Additional data sources can be added to the [Sub search](/v1/docs/en/core-sub-search) via [Joins](/v1/docs/en/core-abstract-join), which are then available for [Projections](/v1/docs/en/core-i-search-projection) in other areas within the [Sub search](/v1/docs/en/core-sub-search). | | **Where** | *Restriction* | The **Where** parameter enables the configuration of [Restrictions](/v1/docs/en/core-i-search-restriction) for the acceptance of instances of the **Entity** within the [Sub search](/v1/docs/en/core-sub-search). - The prefix `_parentQuery` in property paths of the configuration refers – if necessary – to the entity from the *parent* search. - Property paths without this prefix refer to the context given in the [Sub search](/v1/docs/en/core-sub-search), i.e. either to properties of the **Entity** or paths to properties of other entities integrated via **Joins**. | | > [!WARNING] > **IMPORTANT:** > > If the configuration of a **Where** condition is completely omitted in the context of a [Sub search](/v1/docs/en/core-sub-search), then the [Sub search](/v1/docs/en/core-sub-search) is completely ignored when compiling the database query. > > If required, a *pro forma* configured result-neutral **Where** condition (e.g. `id > 0`) ensures that a [Sub search](/v1/docs/en/core-sub-search) is executed, which should either refer to *all* instances of the **Entity** or whose restrictive effect is based on non-optional [Joins](/v1/docs/en/core-abstract-join). | | **Group by** | *Projection* | The configuration of criteria for a **Group by** does not generally represent any added value for the effect of a [Sub search](/v1/docs/en/core-sub-search) as a restriction, as this only checks the existence of at least one result row. | ## Examples ### Simple use case: Recognize orphaned weak references A "weak reference" is a reference to entities whose existence is not considered an obstacle to the deletion of the entity in question. For example, all entities use a "weak reference" to refer to the ID (`id`) of a company account via the "Owner" (`ownerId`) property. A company account that "owns" other entities can therefore be deleted without the owned entities first having to be assigned to a new owner. A [Search](/v1/docs/en/core-search) should list [Users](/v1/docs/en/base-user) for whom the company account referenced as "Owner" (`ownerId`) no longer exists. Configuration: | In a [Search](/v1/docs/en/core-search) for [Users](/v1/docs/en/base-user), the **Where** condition is configured as an AND conjunction as shown on the right: - The [Field restriction](/v1/docs/en/core-property-search) uses a compare (`>0`) to check whether an "owner" is even specified for the user account. **NOTE:** For entities without an owner, the value `-1` appears in the `ownerId` property. - Like the "Owner" property, the [Sub search](/v1/docs/en/core-sub-search) below refers to the "Company account" (`CompanyAccount`) **Entity**. - A **Projection**, **Joins** and criteria for **Group by** are not required. - The **Where** condition uses another instance of the [Field restriction](/v1/docs/en/core-property-search) to check for a match (`==`) between the `ownerId` property of the user account from the parent search (`_parentQuery`) and the "ID" (`id`) property. - The [Sub search](/v1/docs/en/core-sub-search) has been "negated" here, which is indicated by the symbol (!) at the bottom of the [Search junction](/v1/docs/en/core-search-junction) automatically added as a result. Effectively, the **Where** condition of the parent search is passed if the "Owner" property of the user account specifies an ID for which the [Sub search](/v1/docs/en/core-sub-search) does not find a match among all company accounts. As the [Sub search](/v1/docs/en/core-sub-search) ignores any access restrictions, this implies that the company account referenced as the "owner" does not exist (anymore). | ![images/download/attachments/162410478/image-2024-1-3_10-22-38-version-1-modificationdate-1704273758662-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2024-1-3_10-22-38-version-1-modificationdate-1704273758662-api-v2.png) | | --- | --- | ### Typical use case: Incoming reference(s) as a restriction A custom overview (see [Custom overviews](/v1/docs/en/administration-designer-client-preferences-overview)) should only list those [Users](/v1/docs/en/base-user) to whom at least one document (see [Documents](/v1/docs/en/doc-document)) with the [Document type](/v1/docs/en/doc-document-type) "CV" (`CV`) is assigned. **NOTE:** Assigned [Documents](/v1/docs/en/doc-document) refer to the "referenced object" and not vice versa (see [Assigning documents](/v1/docs/en/doc-documents-assign)). Therefore, the properties of *all* [Documents](/v1/docs/en/doc-document) relevant for the reference must be evaluated in order to identify "assigned documents". Configuration: | A [Sub search](/v1/docs/en/core-sub-search) is configured as a **Restriction** for the custom overview as shown on the right: - The "Document" (`Document`) entity type is selected as the **Entity** to be evaluated for the [Sub search](/v1/docs/en/core-sub-search), which is only available if the associated module is installed and licensed. - As a **Where** condition, several instances of the [Field restriction](/v1/docs/en/core-property-search) must be checked within an AND conjunction in order to determine whether the document to be evaluated is assigned to the user account from the *parent* search (*here*: the implicitly generated [Tuple search](/v1/docs/en/core-tuple-search) for the custom overview). Details on the [Search junction](/v1/docs/en/core-search-junction) can be seen below. - The "Referenced object" (`referencedEntity`) property must refer to the "User" [Class](/v1/docs/en/core-class-value-editor). - The "Referenced entity ID" (`referencedEntity`) property must specify the ID of the user account from the *parent* search (`_parentQuery.id`). - The "Reference status" (`referenceStatus`) property must specify the status "Referenced" (`REFERENCED`). - The "Document type" (`documentType`) property must specify the user-defined [Document type](/v1/docs/en/doc-document-type) "Curriculum vitae" (`CV`). | ![images/download/attachments/162410478/image-2024-1-3_10-27-31-version-1-modificationdate-1704274051404-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2024-1-3_10-27-31-version-1-modificationdate-1704274051404-api-v2.png) | | --- | --- | | ![images/download/attachments/162410478/image-2024-1-3_10-28-3-version-1-modificationdate-1704274084054-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2024-1-3_10-28-3-version-1-modificationdate-1704274084054-api-v2.png) | **NOTE:** If access restrictions are effective in the execution context, the custom overview only takes into account [Users](/v1/docs/en/base-user) for whom read access is granted. Accordingly, the incoming references of documents are only checked for these users. Whether there is access to the "qualifying" CV document in the execution context is not decisive, as the [Sub search](/v1/docs/en/core-sub-search) ignores access restrictions. The overview may therefore also show user accounts for whose "CV" document there is no read access. ### Special use case: Identifying duplicates A [Search](/v1/docs/en/core-search) should list all [Companies/Clients](/v1/docs/en/base-company-account) whose address uses an "account number" (`address.accNumber`) that is "ambiguous" – i.e. also assigned to at least one *other* company. Configuration: | Within a [Search](/v1/docs/en/core-search) for [Companies/Clients](/v1/docs/en/base-company-account), a [Sub search](/v1/docs/en/core-sub-search) is configured as the only *restriction* in the **Where** condition, as shown on the right: - Like the *parent* [Search](/v1/docs/en/core-search), the [Sub search](/v1/docs/en/core-sub-search) also refers to the **Entity** "CompanyAccount" (`CompanyAccount`). - The configuration of a **Projection** is not required. - **Joins** are not required. - The **Where** condition of the [Sub search](/v1/docs/en/core-sub-search) uses an AND conjunction with two instances of the [Field restriction](/v1/docs/en/core-property-search) type, each of which compares a property of the company checked by the [Sub search](/v1/docs/en/core-sub-search) with the same property of the company in the *parent* [Search](/v1/docs/en/core-search) (`_parentQuery`). - The first [Field restriction](/v1/docs/en/core-property-search) requires a match (`==`)) for the address property "Account number" (`address.accNumber`). - The second [Field restriction](/v1/docs/en/core-property-search) also requires a difference for the "ID" (`id`) property. - Criteria for **Group by** are not required. --- > [!NOTE] > **NOTE:** > > - In this case, the *parent* search and the [Sub search](/v1/docs/en/core-sub-search) exceptionally relate to the same **Entity**. Typically, the [Sub search](/v1/docs/en/core-sub-search) evaluates a *different* entity type than the *parent* search. > - The fact that both levels of the search relate to the same entity type illustrates the following important difference with regard to access rights to companies: > - The *parent* [Search](/v1/docs/en/core-search) only takes into account [Companies/Clients](/v1/docs/en/base-company-account) that can be accessed in the execution context. The [Sub search](/v1/docs/en/core-sub-search) is therefore only executed for this *subset* of all [Companies/Clients](/v1/docs/en/base-company-account). > - However, the [Sub search](/v1/docs/en/core-sub-search) compares the [Companies/Clients](/v1/docs/en/base-company-account) in the *subset* determined by the possibly restricted access in the *parent* [Search](/v1/docs/en/core-search) with all [Companies/Clients](/v1/docs/en/base-company-account) without taking access restrictions into account in order to search for another company that uses the same account number as the one from the *subset*. | ![images/download/attachments/162410478/image-2024-1-3_10-32-30-version-1-modificationdate-1704274350943-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image-2024-1-3_10-32-30-version-1-modificationdate-1704274350943-api-v2.png) | | --- | --- | **NOTE:** In an execution context with effective access restrictions, the [Search](/v1/docs/en/core-search) returns all [Companies/Clients](/v1/docs/en/base-company-account) whose "account number" is assigned ambiguously AND for which read access exists. Therefore, the search result does not necessarily always show *all* [Companies/Clients](/v1/docs/en/base-company-account) that refer to the same ambiguously assigned account number, but only those for which read access also exists in the execution context. Overlaps between the account numbers of [Companies/Clients](/v1/docs/en/base-company-account) for which there is no read access in the execution context are not evaluated.