---
title: "Advanced search for Result collection"
url: "https://apiportal-qa.np.six-group.com/apis/simulator-ch-qa-v1/versions/c729661a-062a-4141-9704-f637226fa5f0/operations/searchResults"
---

> Full API specification: https://apiportal-qa.np.six-group.com/apis/simulator-ch-qa-v1/versions/c729661a-062a-4141-9704-f637226fa5f0.md

# Advanced search for Result collection

`POST` `/simulations/{simulationId}/results/search`

Operation ID: `searchResults`

**SEARCH** is an experience/resource type API designed to provide support to the search of **RESULT** collection. This is part of the advanced query search. The operation uses the next query objects: * Filters: every filter applied **MUST** be present with the provided value set. * Restrictions: every object returned in the collection **MUST** be validated on the restriction. Every restriction and filter is applied with **AND** operation. As example: POST /simulations/{simulationsId}/results/search { "filters": [ { "attribute": "attributeId", "values": [ "attributeValue" ] } ], "restrictions": [ { "attribute": "numericAttributeId", "type": "decimal", "operator": "and", "values": [ { "restriction": "lte", "value": "2.0" }, { "restriction": "gte", "value": "1.0" } ] } ] } This is equivalent to: **WHERE** attributeId **IN** ("attributeValue") **AND** numericAttributeId **>** 1.0 **AND** numericAttributeId **<** 2.0 Results could be ordered by any field.

## Path parameters

- `simulationId` (string, string, required) - Resource ID in **UUID** format

## Query parameters

- `page[size]` (integer, optional) - Pagination options for the collection search. It permits the next modifiers: * page[size] * page[number] Default values defined are page[number]=1 and page[size]=20
- `page[number]` (integer, optional) - Pagination options for the collection search. It permits the next modifiers: * page[size] * page[number] Default values defined are page[number]=1 and page[size]=20
- `sort` (string, optional) - Sort query parameter permits the sorting of the collection by the values of the attribute provided in the parameter: GET simulations?sort=+attribute The type of sort: * (+) Indicates ascending order. +attribute * (-) Indicates descending order. -attribute * If no symbol is provided, any default order could be returned **If sort is not provided, the collection is returned in a default order by ID.** The name of the attribute should exists in the object. If the name does not exists, it returns **400 Bad Request**.

## Request body

Content types: `application/json`

## Responses

- `200` - Ok
- `400` - Bad Request
- `401` - Unauthorized
- `403` - Forbidden
- `500` - Internal Server Error

## OpenAPI definition

```yaml
openapi: 3.0.2
info:
  title: DCleaR - Risk Simulator API - v1
  version: 1.0.0
servers:
  - url: https://api-qa.np.six-group.com/clearing/risk/simulator/dev/v1
  - url: https://api-qa.np.p2p.six-group.com/clearing/risk/simulator/dev/v1
  - url: https://api-qa.np.fip.six-group.com/clearing/risk/simulator/dev/v1
paths:
  /simulations/{simulationId}/results/search:
    parameters:
      - name: simulationId
        in: path
        description: Resource ID in **UUID** format
        required: true
        style: simple
        explode: false
        schema:
          $ref: "#/components/schemas/UUIDType"
      - name: page[size]
        in: query
        description: "Pagination options for the collection search. It permits the next
          modifiers:\r

          \  * page[size]\r

          \  * page[number]\r

          \r

          Default values defined are page[number]=1 and page[size]=20"
        required: false
        style: form
        explode: true
        schema:
          type: integer
        examples:
          Page size = 20:
            value: 20
      - name: page[number]
        in: query
        description: "Pagination options for the collection search. It permits the next
          modifiers:\r

          \  * page[size]\r

          \  * page[number]\r

          \r

          Default values defined are page[number]=1 and page[size]=20"
        required: false
        style: form
        explode: true
        schema:
          type: integer
        examples:
          Page number = 3:
            value: 3
      - name: sort
        in: query
        description: >-
          Sort query parameter permits the sorting of the collection by the
          values of the attribute provided in the parameter:

              GET simulations?sort=+attribute

          The type of sort:

           * (+) Indicates ascending order. +attribute
           * (-) Indicates descending order. -attribute
           * If no symbol is provided, any default order could be returned

          **If sort is not provided, the collection is returned in a default
          order by ID.**


          The name of the attribute should exists in the object. If the name
          does not exists, it returns **400 Bad Request**.
        required: false
        style: form
        explode: true
        schema:
          type: string
        examples:
          Sort by attribute:
            value: attribute
          Sort by attribute, ascending:
            value: +attribute
          Sort by attribute, descending:
            value: -attribute
          Sort by attribute ascending, something descending:
            value: +attribute,-something
    post:
      tags:
        - Results
      summary: Advanced search for Result collection
      description: >-
        **SEARCH** is an experience/resource type API designed to provide
        support to the search of **RESULT** collection. This is part of the
        advanced query search.


        The operation uses the next query objects:
          * Filters: every filter applied **MUST** be present with the provided value set.
          * Restrictions: every object returned in the collection **MUST** be validated on the restriction. 

        Every restriction and filter is applied with **AND** operation. As
        example:

            POST /simulations/{simulationsId}/results/search
            {
                "filters": [
                    {
                        "attribute": "attributeId",
                        "values": [
                            "attributeValue"
                        ]
                    }

                ], 
                "restrictions": [
                    {
                      "attribute": "numericAttributeId",
                      "type": "decimal",
                      "operator": "and",
                      "values": [
                          {
                            "restriction": "lte",
                            "value": "2.0"
                        },
                        {
                            "restriction": "gte",
                            "value": "1.0"
                        }
                    ]
                  }
                ]
            }

        This is equivalent to: **WHERE** attributeId **IN** ("attributeValue")
        **AND** numericAttributeId **>** 1.0 **AND** numericAttributeId **<**
        2.0


        Results could be ordered by any field.
      operationId: searchResults
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/QueryType"
            examples:
              QuerySearch:
                value:
                  filters:
                    - attribute: attributeId
                      values:
                        - attributeValue
                  restrictions:
                    - attribute: numericAttributeId
                      type: decimal
                      operator: and
                      values:
                        - restriction: lte
                          value: "2.0"
                        - restriction: gte
                          value: "1.0"
      responses:
        "200":
          $ref: "#/components/responses/200OkResults"
        "400":
          $ref: "#/components/responses/400ErrorResponse"
        "401":
          $ref: "#/components/responses/401SecurityLayerErrorResponse"
        "403":
          $ref: "#/components/responses/403SecurityLayerErrorResponse"
        "500":
          $ref: "#/components/responses/500ErrorResponse"
components:
  schemas:
    UUIDType:
      pattern: ^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$
      type: string
      description: UUID type implementing the [RFC
        4122](https://www.ietf.org/rfc/rfc4122.txt).
      format: string
      example: 95b1b467-bd69-4436-8181-96c16408c230
    QueryType:
      type: object
      properties:
        filters:
          type: array
          description: Filters restricting the search. All of the values in the Array
            represent AND operation.
          items:
            $ref: "#/components/schemas/FilterType"
        restrictions:
          type: array
          description: List of restrictions applied to the collection
          items:
            $ref: "#/components/schemas/RestrictionRootType"
    FilterType:
      type: object
      properties:
        attribute:
          type: string
          description: Name of the attribute to be restricted, filtered or searched
          example: sessionDate
        values:
          type: array
          description: Value of the filter or restriction done.
          example:
            - "20200101"
            - "20200102"
          items:
            type: string
    RestrictionRootType:
      required:
        - operator
      type: object
      properties:
        attribute:
          type: string
          description: Name of the attribute to be restricted, filtered or searched
          example: high
        type:
          type: string
          description: Type of the value to be searched. This is used to validate the
            transformation done in the backend once the list is received
          example: decimal
          enum:
            - integer
            - decimal
            - string
            - boolean
        operator:
          type: string
          description: Operator applied in the value comparision.
          example: and
          enum:
            - and
            - or
        values:
          type: array
          description: List of restrictions to be applied with the operator in the attribute
          items:
            $ref: "#/components/schemas/RestrictionType"
    ResultsJsonApiType:
      required:
        - data
        - links
        - meta
      type: object
      properties:
        links:
          $ref: "#/components/schemas/LinksPaginationType"
        data:
          type: array
          description: List of **MESSAGES** present in the collection, resulting on the
            query request.
          readOnly: true
          items:
            $ref: "#/components/schemas/ResultType"
        meta:
          $ref: "#/components/schemas/MetaType"
      description: Collection in JSON:API format. Collection is paginated
    Error:
      required:
        - message
      type: object
      properties:
        message:
          type: string
          description: A human-readable explanation specific to this error.
          example: Unauthorized
        errorDetail:
          description: Additional information about the error.
          allOf:
            - $ref: "#/components/schemas/ErrorDetail"
      description: Description of an error to help remediation.
    RestrictionType:
      type: object
      properties:
        restriction:
          type: string
          description: Type of restriction to be set in the search, if applies
          example: lt
          enum:
            - lt
            - lte
            - gt
            - gte
            - eqt
            - neqt
            - like
        value:
          type: string
          description: Value of the filter or restriction done.
          example: "2.3"
    LinksPaginationType:
      required:
        - first
        - last
      type: object
      properties:
        first:
          type: string
          description: First position of the collection
          example: https://api.domain.com/resources?page[number]=1
        last:
          type: string
          description: Last page of the collection
          example: https://api.domain.com/resources?page[number]=50
        prev:
          type: string
          description: Navigates to the previous page on the list provided. If the page is
            the first one, prev should be null or not be present
          example: https://api.domain.com/resources?page[number]=1
        next:
          type: string
          description: Navigates to the next page on the list provided. If the page is the
            last one, prev should be null or not be present
          example: https://api.domain.com/resources?page[number]=3
    ResultType:
      type: object
      description: Data structure for all operations.
      allOf:
        - type: object
          properties:
            attributes:
              $ref: "#/components/schemas/ResultAttributesType"
        - $ref: "#/components/schemas/BasicResourceType"
    MetaType:
      type: object
      properties:
        history:
          $ref: "#/components/schemas/MetaHistoryType"
        pagination:
          $ref: "#/components/schemas/PaginationType"
    ErrorDetail:
      required:
        - status
      type: object
      properties:
        type:
          type: string
          description: >-
            A URI reference (RFC3986) that describes the problem type (in the
            context of the provided API).


            Should resolve to a human-readable document.
          format: uri
          default: about:blank
        title:
          type: string
          description: A short, human-readable summary of the problem type in English.
          example: Not Found
        status:
          maximum: 599
          minimum: 100
          type: integer
          description: The HTTP status code (RFC7231, Section 6) generated by the origin
            server for this occurrence of the problem.
          format: int32
          example: 400
        code:
          $ref: "#/components/schemas/ServerErrorCode"
        detail:
          type: string
          description: A human-readable explanation specific to this occurrence of the
            problem.
          example: ISIN 'US012071998' does not exist.
        instance:
          type: string
          description: A URI reference (RFC3986) that identifies the specific occurrence
            of the problem. It may or may not yield further information if
            dereferenced.
          format: uri
          example: https://www.example.com/books/1234
        missingParams:
          type: array
          items:
            $ref: "#/components/schemas/MissingParams"
        invalidParams:
          type: array
          items:
            $ref: "#/components/schemas/InvalidParams"
      description: Detailed description of an error to help remediation. It follows
        RFC 7807 (https://datatracker.ietf.org/doc/html/rfc7807).
    ResultAttributesType:
      required:
        - baseInitialMargin
        - finalInitialMargin
        - member
        - positionSizeAdjustment
        - wrongWayRisk
      type: object
      properties:
        member:
          maxLength: 50
          minLength: 1
          type: string
          description: Name of the member account for the IM group calculation
          example: Member-1
        baseInitialMargin:
          type: number
          description: Initial margin is the percentage of the purchase price of a
            security that must be covered by cash or collateral when using a
            margin account
          format: double
          example: 100
        positionSizeAdjustment:
          type: number
          description: The number of units invested in a particular security by an
            investor or trader
          format: double
          example: 50
        wrongWayRisk:
          type: number
          description: In the field of finance, a wrong way risk (WWR) occurs when credit
            exposure to a counterparty is negatively correlated with the credit
            quality of that counterparty
          format: double
          example: 45
        finalInitialMargin:
          type: number
          description: Aggregated value of baseInitialMargin, positionSizeAdjustment and
            wrongWayRisk.
          format: double
          example: 195
      description: Basic attributes of the object.
    BasicResourceType:
      required:
        - type
      type: object
      properties:
        id:
          $ref: "#/components/schemas/UUIDType"
        type:
          type: string
          description: Type of the resource attributes being represented
          example: simulation
          enum:
            - simulation
            - calculation
            - result
            - open-position
            - import-open-positions
            - result-detail
            - report
    MetaHistoryType:
      title: MetaHistoryType
      required:
        - created
      type: object
      properties:
        created:
          type: string
          description: When the JSON:API Object has been created
          format: date-time
          example: 2022-01-02T18:25:43.511Z
        createdBy:
          type: string
          description: Who created the JSON:API object. This should not share login
            information (by example, use email)
          example: chris.doe@sixgroup.com
        lastModified:
          type: string
          description: When the object has been modified by the last time. This is
            optional value.
          format: date-time
          example: 2022-01-02T18:25:43.511Z
        lastModifiedBy:
          type: string
          description: Who modified the JSON:API object.
          example: michael.rodriguez@sixgroup.com
        version:
          type: string
          description: This is the version of the object. Should contain hash of the
            object to detect if this has changed before commit again new
            changes.
          example: AF9e94334rr44
      description: Contains the historical information object
    PaginationType:
      title: PaginationType
      type: object
      properties:
        totalEntities:
          type: integer
          description: >-
            Total of the entities returned in the collection. Depending of the
            operation pattern:
             * SEARCH: return the number of elements of the search criteria
             * GET: return all the elements or the search criteria
          format: int32
        totalPages:
          type: integer
          description: "Total of the pages that the collection could return. Last page =
            to totalPages. "
          format: int32
        pageSize:
          type: integer
          description: Size of the page.
          format: int32
        page:
          type: integer
          description: Current Page of the return collection
          format: int32
    ServerErrorCode:
      pattern: ^[0-9A-Z_]{1,125}$
      type: string
      description: "An application specific error code that identifies univocally the
        error situation. "
      example: THIS_IS_ERROR_CODE
    MissingParams:
      type: object
      properties:
        in:
          $ref: "#/components/schemas/ParameterLocation"
        name:
          type: string
        reason:
          type: string
        code:
          $ref: "#/components/schemas/ServerErrorCode"
      description: "List of missing parameters.\r

        \r

        ***Please note that the API GW does syntax validation according to the
        OAS and will issue an error response in case of failure. Thus, this
        extension should only be used when the API server is not connected to
        via the API GW or if conditional presence conditions (that typically
        cannot be modeled in an OAS) are applicable.***"
      example:
        in: PATH
        name: paramName
        reason: The parameter 'paramName' is not present in PATH
        code: ERROR_INTERNAL
    InvalidParams:
      required:
        - in
        - name
        - value
      type: object
      properties:
        in:
          $ref: "#/components/schemas/ParameterLocation"
        name:
          type: string
          description: The name of the invalid parameter.
        reason:
          type: string
          description: The reason why the parameter's value is invalid.
        code:
          $ref: "#/components/schemas/ServerErrorCode"
        value:
          type: string
          description: The invalid value (as a string).
      description: "List of invalid parameters.\r

        \r

        ***Please note that the API GW does syntax validation according to the
        OAS and will issue an error response in case of failure. Thus, this
        extension should only be used when the API server is not connected to
        via the API GW or if additional (to what is defined in the OAS) checks
        are performed.***"
      example:
        in: PATH
        name: paramName
        reason: Internal functional validation has ended in failure
        value: "23.3"
        code: ERROR_INTERNAL
    ParameterLocation:
      type: string
      description: The location of the invalid parameter.
      enum:
        - BODY
        - PATH
        - QUERY
        - HEADER
  responses:
    200OkResults:
      description: Ok
      headers:
        X-Correlation-Id:
          style: simple
          explode: false
          schema:
            $ref: "#/components/schemas/UUIDType"
      content:
        application/vnd.api+json:
          schema:
            $ref: "#/components/schemas/ResultsJsonApiType"
          examples:
            200 Ok Results:
              value:
                links:
                  first: https://api.domain.com/resources?page[number]=1
                  last: https://api.domain.com/resources?page[number]=50
                  prev: https://api.domain.com/resources?page[number]=1
                  next: https://api.domain.com/resources?page[number]=3
                data:
                  - attributes:
                      member: Member-1
                      baseInitialMargin: 100
                      positionSizeAdjustment: 50
                      wrongWayRisk: 45
                      finalInitialMargin: 195
                    id: 95b1b467-bd69-4436-8181-96c16408c230
                    type: result
                meta:
                  history:
                    created: 2022-01-02T18:25:43.511Z
                    createdBy: chris.doe@sixgroup.com
                    lastModified: 2022-01-02T18:25:43.511Z
                    lastModifiedBy: michael.rodriguez@sixgroup.com
                    version: AF9e94334rr44
                  pagination:
                    totalEntities: 0
                    totalPages: 0
                    pageSize: 0
                    page: 0
    400ErrorResponse:
      description: Bad Request
      headers:
        X-Correlation-Id:
          style: simple
          explode: false
          schema:
            $ref: "#/components/schemas/UUIDType"
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/Error"
          examples:
            BadRequestMissingAttributes:
              value:
                message: Bad Requet
                errorDetail:
                  type: about:blank
                  title: Bad Request
                  status: 400
                  code: A123
                  detail: Wrong input value
                  missingParams:
                    - in: PATH
                      name: paramName
                      reason: The parameter 'paramName' is not present in PATH
                      code: ERROR_INTERNAL
                  invalidParams:
                    - in: PATH
                      name: paramName
                      reason: Internal functional validation has ended in failure
                      value: "23.3"
                      code: ERROR_INTERNAL
    401SecurityLayerErrorResponse:
      description: Unauthorized
      headers:
        X-Correlation-Id:
          style: simple
          explode: false
          schema:
            $ref: "#/components/schemas/UUIDType"
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/Error"
          examples:
            Unauthorized:
              value:
                message: No required TLS certificate was sent
                errorDetail:
                  title: Unauthorized
                  status: 401
                  detail: Client is not authenticated.
    403SecurityLayerErrorResponse:
      description: Forbidden
      headers:
        X-Correlation-Id:
          style: simple
          explode: false
          schema:
            $ref: "#/components/schemas/UUIDType"
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/Error"
          examples:
            Forbidden:
              value:
                message: Forbidden
                errorDetail:
                  title: Forbidden
                  status: 403
                  detail: Client is not authorized for this operation.
    500ErrorResponse:
      description: Internal Server Error
      headers:
        X-Correlation-Id:
          style: simple
          explode: false
          schema:
            $ref: "#/components/schemas/UUIDType"
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/Error"
          examples:
            ServerError:
              value:
                message: Server error
                errorDetail:
                  title: Internal Server Error
                  status: 500
                  detail: Something went wrong.
```
