Search Collection Records

This document provides comprehensive instructions on how to utilize the search functionality provided by the Collection API to effectively query records within a collection.

Endpoint

The search functionality is accessible via the following API endpoint:
POST /collection-records/search

Request Body
To execute a search query, you need to include the search criteria in the request body using the searchInput object. Below is a breakdown of the request body structure along with a sample request:

{
  "tenant": {
    "accountId": "accountID",
    "moduleId": "moduleId"
  },
  "collectionId": "collectionId",
  "searchInput": {
    "selection": {
      "matchType": "All",
      "filters": [
        {
          "field": "fieldName",
          "operator": "contains",
          "value": "xyz"
        }
      ]
    }
  },
  "pagination": {
      "from": 0,
      "size": 10
   }
}

SearchInput Object
The searchInput object allows you to define the search criteria in detail. It comprises the following components:

  • selection: Specifies the match type and filters to be applied to the search.
  • matchType: Indicates whether all or any of the specified filters must match.
  • filters: An array of filter objects, each representing a search condition.

Filter Object
Each filter object represents a condition to be applied to the search. It includes the following properties:

  • field: The field within the collection to search.
  • operator: The comparison operator to use for the search.
  • value: The value to compare against.

Pagination
To implement pagination, include the pagination object in the request body. It specifies the starting index (from) and the number of items per page (size).


  "pagination": {
    "from": 0,
    "size": 100
  }

Match Types
The match type determines the behavior of the search operation. There are two available match types:

  • All: Requires all specified filters to match for a record to be included in the search results.
  • Any: Requires at least one of the specified filters to match for a record to be included in the search results.

Condition Types
The condition type specifies the comparison operator used in the search condition. The following condition types are supported:

  • gt: Greater than
  • gte: Greater than or equal to
  • lt: Less than
  • lte: Less than or equal to
  • eq: Equals
  • ne: Not equal to
  • in: In array
  • nin: Not in array
  • contains: Contains substring
  • notContains: Does not contain substring
  • isEmpty: Is empty
  • isNotEmpty: Is not empty

Usage Instructions
To effectively utilize the search functionality:

  1. Send a POST request to the /collection-records/search endpoint, providing the necessary search criteria in the request body.
  2. Receive the search results in the response object and process them accordingly.

By following these steps, you can successfully leverage the search functionality provided by the Collection API to query records within a collection.