SearchResourcesCommand

Searches metadata and the content of folders, documents, document versions, and comments.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { WorkDocsClient, SearchResourcesCommand } from "@aws-sdk/client-workdocs"; // ES Modules import
// const { WorkDocsClient, SearchResourcesCommand } = require("@aws-sdk/client-workdocs"); // CommonJS import
const client = new WorkDocsClient(config);
const input = { // SearchResourcesRequest
  AuthenticationToken: "STRING_VALUE",
  QueryText: "STRING_VALUE",
  QueryScopes: [ // SearchQueryScopeTypeList
    "NAME" || "CONTENT",
  ],
  OrganizationId: "STRING_VALUE",
  AdditionalResponseFields: [ // AdditionalResponseFieldsList
    "WEBURL",
  ],
  Filters: { // Filters
    TextLocales: [ // TextLocaleTypeList
      "AR" || "BG" || "BN" || "DA" || "DE" || "CS" || "EL" || "EN" || "ES" || "FA" || "FI" || "FR" || "HI" || "HU" || "ID" || "IT" || "JA" || "KO" || "LT" || "LV" || "NL" || "NO" || "PT" || "RO" || "RU" || "SV" || "SW" || "TH" || "TR" || "ZH" || "DEFAULT",
    ],
    ContentCategories: [ // SearchContentCategoryTypeList
      "IMAGE" || "DOCUMENT" || "PDF" || "SPREADSHEET" || "PRESENTATION" || "AUDIO" || "VIDEO" || "SOURCE_CODE" || "OTHER",
    ],
    ResourceTypes: [ // SearchResourceTypeList
      "FOLDER" || "DOCUMENT" || "COMMENT" || "DOCUMENT_VERSION",
    ],
    Labels: [ // SearchLabelList
      "STRING_VALUE",
    ],
    Principals: [ // SearchPrincipalTypeList
      { // SearchPrincipalType
        Id: "STRING_VALUE", // required
        Roles: [ // SearchPrincipalRoleList
          "VIEWER" || "CONTRIBUTOR" || "OWNER" || "COOWNER",
        ],
      },
    ],
    AncestorIds: [ // SearchAncestorIdList
      "STRING_VALUE",
    ],
    SearchCollectionTypes: [ // SearchCollectionTypeList
      "OWNED" || "SHARED_WITH_ME",
    ],
    SizeRange: { // LongRangeType
      StartValue: Number("long"),
      EndValue: Number("long"),
    },
    CreatedRange: { // DateRangeType
      StartValue: new Date("TIMESTAMP"),
      EndValue: new Date("TIMESTAMP"),
    },
    ModifiedRange: {
      StartValue: new Date("TIMESTAMP"),
      EndValue: new Date("TIMESTAMP"),
    },
  },
  OrderBy: [ // SearchResultSortList
    { // SearchSortResult
      Field: "RELEVANCE" || "NAME" || "SIZE" || "CREATED_TIMESTAMP" || "MODIFIED_TIMESTAMP",
      Order: "ASC" || "DESC",
    },
  ],
  Limit: Number("int"),
  Marker: "STRING_VALUE",
};
const command = new SearchResourcesCommand(input);
const response = await client.send(command);
// { // SearchResourcesResponse
//   Items: [ // ResponseItemsList
//     { // ResponseItem
//       ResourceType: "DOCUMENT" || "FOLDER" || "COMMENT" || "DOCUMENT_VERSION",
//       WebUrl: "STRING_VALUE",
//       DocumentMetadata: { // DocumentMetadata
//         Id: "STRING_VALUE",
//         CreatorId: "STRING_VALUE",
//         ParentFolderId: "STRING_VALUE",
//         CreatedTimestamp: new Date("TIMESTAMP"),
//         ModifiedTimestamp: new Date("TIMESTAMP"),
//         LatestVersionMetadata: { // DocumentVersionMetadata
//           Id: "STRING_VALUE",
//           Name: "STRING_VALUE",
//           ContentType: "STRING_VALUE",
//           Size: Number("long"),
//           Signature: "STRING_VALUE",
//           Status: "INITIALIZED" || "ACTIVE",
//           CreatedTimestamp: new Date("TIMESTAMP"),
//           ModifiedTimestamp: new Date("TIMESTAMP"),
//           ContentCreatedTimestamp: new Date("TIMESTAMP"),
//           ContentModifiedTimestamp: new Date("TIMESTAMP"),
//           CreatorId: "STRING_VALUE",
//           Thumbnail: { // DocumentThumbnailUrlMap
//             "<keys>": "STRING_VALUE",
//           },
//           Source: { // DocumentSourceUrlMap
//             "<keys>": "STRING_VALUE",
//           },
//         },
//         ResourceState: "ACTIVE" || "RESTORING" || "RECYCLING" || "RECYCLED",
//         Labels: [ // SharedLabels
//           "STRING_VALUE",
//         ],
//       },
//       FolderMetadata: { // FolderMetadata
//         Id: "STRING_VALUE",
//         Name: "STRING_VALUE",
//         CreatorId: "STRING_VALUE",
//         ParentFolderId: "STRING_VALUE",
//         CreatedTimestamp: new Date("TIMESTAMP"),
//         ModifiedTimestamp: new Date("TIMESTAMP"),
//         ResourceState: "ACTIVE" || "RESTORING" || "RECYCLING" || "RECYCLED",
//         Signature: "STRING_VALUE",
//         Labels: [
//           "STRING_VALUE",
//         ],
//         Size: Number("long"),
//         LatestVersionSize: Number("long"),
//       },
//       CommentMetadata: { // CommentMetadata
//         CommentId: "STRING_VALUE",
//         Contributor: { // User
//           Id: "STRING_VALUE",
//           Username: "STRING_VALUE",
//           EmailAddress: "STRING_VALUE",
//           GivenName: "STRING_VALUE",
//           Surname: "STRING_VALUE",
//           OrganizationId: "STRING_VALUE",
//           RootFolderId: "STRING_VALUE",
//           RecycleBinFolderId: "STRING_VALUE",
//           Status: "ACTIVE" || "INACTIVE" || "PENDING",
//           Type: "USER" || "ADMIN" || "POWERUSER" || "MINIMALUSER" || "WORKSPACESUSER",
//           CreatedTimestamp: new Date("TIMESTAMP"),
//           ModifiedTimestamp: new Date("TIMESTAMP"),
//           TimeZoneId: "STRING_VALUE",
//           Locale: "en" || "fr" || "ko" || "de" || "es" || "ja" || "ru" || "zh_CN" || "zh_TW" || "pt_BR" || "default",
//           Storage: { // UserStorageMetadata
//             StorageUtilizedInBytes: Number("long"),
//             StorageRule: { // StorageRuleType
//               StorageAllocatedInBytes: Number("long"),
//               StorageType: "UNLIMITED" || "QUOTA",
//             },
//           },
//         },
//         CreatedTimestamp: new Date("TIMESTAMP"),
//         CommentStatus: "DRAFT" || "PUBLISHED" || "DELETED",
//         RecipientId: "STRING_VALUE",
//         ContributorId: "STRING_VALUE",
//       },
//       DocumentVersionMetadata: {
//         Id: "STRING_VALUE",
//         Name: "STRING_VALUE",
//         ContentType: "STRING_VALUE",
//         Size: Number("long"),
//         Signature: "STRING_VALUE",
//         Status: "INITIALIZED" || "ACTIVE",
//         CreatedTimestamp: new Date("TIMESTAMP"),
//         ModifiedTimestamp: new Date("TIMESTAMP"),
//         ContentCreatedTimestamp: new Date("TIMESTAMP"),
//         ContentModifiedTimestamp: new Date("TIMESTAMP"),
//         CreatorId: "STRING_VALUE",
//         Thumbnail: {
//           "<keys>": "STRING_VALUE",
//         },
//         Source: {
//           "<keys>": "STRING_VALUE",
//         },
//       },
//     },
//   ],
//   Marker: "STRING_VALUE",
// };

SearchResourcesCommand Input

See SearchResourcesCommandInput for more details

Parameter
Type
Description
AdditionalResponseFields
AdditionalResponseFieldType[] | undefined

A list of attributes to include in the response. Used to request fields that are not normally returned in a standard response.

AuthenticationToken
string | undefined

Amazon WorkDocs authentication token. Not required when using Amazon Web Services administrator credentials to access the API.

Filters
Filters | undefined

Filters results based on entity metadata.

Limit
number | undefined

Max results count per page.

Marker
string | undefined

The marker for the next set of results.

OrderBy
SearchSortResult[] | undefined

Order by results in one or more categories.

OrganizationId
string | undefined

Filters based on the resource owner OrgId. This is a mandatory parameter when using Admin SigV4 credentials.

QueryScopes
SearchQueryScopeType[] | undefined

Filter based on the text field type. A Folder has only a name and no content. A Comment has only content and no name. A Document or Document Version has a name and content

QueryText
string | undefined

The String to search for. Searches across different text fields based on request parameters. Use double quotes around the query string for exact phrase matches.

SearchResourcesCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
Items
ResponseItem[] | undefined

List of Documents, Folders, Comments, and Document Versions matching the query.

Marker
string | undefined

The marker to use when requesting the next set of results. If there are no additional results, the string is empty.

Throws

Name
Fault
Details
InvalidArgumentException
client

The pagination marker or limit fields are not valid.

ServiceUnavailableException
server

One or more of the dependencies is unavailable.

UnauthorizedOperationException
client

The operation is not permitted.

UnauthorizedResourceAccessException
client

The caller does not have access to perform the action on the resource.

WorkDocsServiceException
Base exception class for all service exceptions from WorkDocs service.