searchByCQL method

Future<SearchPageResponseSearchResult> searchByCQL({
  1. required String cql,
  2. String? cqlcontext,
  3. String? cursor,
  4. bool? next,
  5. bool? prev,
  6. int? limit,
  7. int? start,
  8. bool? includeArchivedSpaces,
  9. bool? excludeCurrentSpaces,
  10. String? excerpt,
  11. String? sitePermissionTypeFilter,
  12. int? $,
  13. List<String>? expand,
})

Searches for content using the Confluence Query Language (CQL).

Note that CQL input queries submitted through the /wiki/rest/api/search endpoint no longer support user-specific fields like user, user.fullname, user.accountid, and user.userkey. See this deprecation notice for more details.

Example initial call:

/wiki/rest/api/search?cql=type=page&limit=25

Example response:

{
  "results": [
    { ... },
    { ... },
    ...
    { ... }
  ],
  "limit": 25,
  "size": 25,
  ...
  "_links": {
    "base": "<url>",
    "context": "<url>",
    "next": "/rest/api/search?cql=type=page&limit=25&cursor=raNDoMsTRiNg",
    "self": "<url>"
  }
}

When additional results are available, returns next and prev URLs to retrieve them in subsequent calls. The URLs each contain a cursor that points to the appropriate set of results. Use limit to specify the number of results returned in each call.

Example subsequent call (taken from example response):

/wiki/rest/api/search?cql=type=page&limit=25&cursor=raNDoMsTRiNg

The response to this will have a prev URL similar to the next in the example response.

Permissions required: Permission to view the entities. Note, only entities that the user has permission to view will be returned.

Implementation

Future<SearchPageResponseSearchResult> searchByCQL(
    {required String cql,
    String? cqlcontext,
    String? cursor,
    bool? next,
    bool? prev,
    int? limit,
    int? start,
    bool? includeArchivedSpaces,
    bool? excludeCurrentSpaces,
    String? excerpt,
    String? sitePermissionTypeFilter,
    int? $,
    List<String>? expand}) async {
  return SearchPageResponseSearchResult.fromJson(await _client.send(
    'get',
    'wiki/rest/api/search',
    queryParameters: {
      'cql': cql,
      if (cqlcontext != null) 'cqlcontext': cqlcontext,
      if (cursor != null) 'cursor': cursor,
      if (next != null) 'next': '$next',
      if (prev != null) 'prev': '$prev',
      if (limit != null) 'limit': '$limit',
      if (start != null) 'start': '$start',
      if (includeArchivedSpaces != null)
        'includeArchivedSpaces': '$includeArchivedSpaces',
      if (excludeCurrentSpaces != null)
        'excludeCurrentSpaces': '$excludeCurrentSpaces',
      if (excerpt != null) 'excerpt': excerpt,
      if (sitePermissionTypeFilter != null)
        'sitePermissionTypeFilter': sitePermissionTypeFilter,
      if ($ != null) '_': '${$}',
      if (expand != null) 'expand': expand.map((e) => e).join(','),
    },
  ));
}