searchUsers method

Future<SearchUsersResponse> searchUsers({
  1. required String collectionId,
  2. String? faceId,
  3. int? maxUsers,
  4. String? userId,
  5. double? userMatchThreshold,
})

Searches for UserIDs within a collection based on a FaceId or UserId. This API can be used to find the closest UserID (with a highest similarity) to associate a face. The request must be provided with either FaceId or UserId. The operation returns an array of UserID that match the FaceId or UserId, ordered by similarity score with the highest similarity first.

May throw AccessDeniedException. May throw InternalServerError. May throw InvalidParameterException. May throw ProvisionedThroughputExceededException. May throw ResourceNotFoundException. May throw ThrottlingException.

Parameter collectionId : The ID of an existing collection containing the UserID, used with a UserId or FaceId. If a FaceId is provided, UserId isn’t required to be present in the Collection.

Parameter faceId : ID for the existing face.

Parameter maxUsers : Maximum number of identities to return.

Parameter userId : ID for the existing User.

Parameter userMatchThreshold : Optional value that specifies the minimum confidence in the matched UserID to return. Default value of 80.

Implementation

Future<SearchUsersResponse> searchUsers({
  required String collectionId,
  String? faceId,
  int? maxUsers,
  String? userId,
  double? userMatchThreshold,
}) async {
  _s.validateNumRange(
    'maxUsers',
    maxUsers,
    1,
    500,
  );
  _s.validateNumRange(
    'userMatchThreshold',
    userMatchThreshold,
    0,
    100,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'RekognitionService.SearchUsers'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'CollectionId': collectionId,
      if (faceId != null) 'FaceId': faceId,
      if (maxUsers != null) 'MaxUsers': maxUsers,
      if (userId != null) 'UserId': userId,
      if (userMatchThreshold != null)
        'UserMatchThreshold': userMatchThreshold,
    },
  );

  return SearchUsersResponse.fromJson(jsonResponse.body);
}