职位基础知识

一个职位资源就是一条招聘信息(也称为“职位列表”或“职位申请”)。职位属于公司资源,代表负责提供该职位的雇用实体。

您可以使用 LIST 和 GET 方法访问职位,并使用 CREATE、UPDATE 和 DELETE 方法进行操控。Cloud Talent Solution 索引可能需要几分钟才能反映所做的更改。

职位包含在服务帐号的范围内。只有使用特定服务帐号的凭据经过身份验证的搜索请求,才能用于访问这些招聘信息的内容。

为了便于排查问题和分类,请将 Cloud Talent Solution 职位索引与您自己的职位索引同步,并维护 Cloud Talent Solution 生成的 name 与系统中唯一的职位标识符之间的关系。当职位发生变更或被引入您的系统时,应将相应的 CRUD 调用实时发送到 Cloud Talent Solution (CTS),以确保这些变更能够立即生效。必须将 CTS 索引添加到现有职位提取管道。

创建作业

您可以使用以下代码示例创建职位。 如需了解详情,请参阅快速入门:创建公司和职位。 此外,还有视频教程和交互式 Codelab 可供使用

Go

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	talentpb "google.golang.org/genproto/googleapis/cloud/talent/v4beta1"
)

// createJob create a job as given.
func createJob(w io.Writer, projectID, companyID, requisitionID, title, URI, description, address1, address2, languageCode string) (*talentpb.Job, error) {
	ctx := context.Background()

	// Initialize a jobService client.
	c, err := talent.NewJobClient(ctx)
	if err != nil {
		fmt.Printf("talent.NewJobClient: %v\n", err)
		return nil, err
	}

	jobToCreate := &talentpb.Job{
		CompanyName:   fmt.Sprintf("projects/%s/companies/%s", projectID, companyID),
		RequisitionId: requisitionID,
		Title:         title,
		ApplicationInfo: &talentpb.Job_ApplicationInfo{
			Uris: []string{URI},
		},
		Description:  description,
		Addresses:    []string{address1, address2},
		LanguageCode: languageCode,
	}

	// Construct a createJob request.
	req := &talentpb.CreateJobRequest{
		Parent: fmt.Sprintf("projects/%s", projectID),
		Job:    jobToCreate,
	}

	resp, err := c.CreateJob(ctx, req)
	if err != nil {
		fmt.Printf("Failed to create job: %v\n", err)
		return nil, err
	}

	fmt.Printf("Created job: %q\n", resp.GetName())

	return resp, nil
}

Java

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库


import com.google.cloud.talent.v4beta1.CreateJobRequest;
import com.google.cloud.talent.v4beta1.Job;
import com.google.cloud.talent.v4beta1.JobServiceClient;
import com.google.cloud.talent.v4beta1.TenantName;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

public class JobSearchCreateJob {

  public static void createJob() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    String companyId = "your-company-id";
    String requisitionId = "your-unique-req-id";
    String jobApplicationUrl = "your-job-url";
    createJob(projectId, tenantId, companyId, requisitionId, jobApplicationUrl);
  }

  // Create a job.
  public static void createJob(
      String projectId,
      String tenantId,
      String companyId,
      String requisitionId,
      String jobApplicationUrl)
      throws IOException {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
      TenantName parent = TenantName.of(projectId, tenantId);
      Job.ApplicationInfo applicationInfo =
          Job.ApplicationInfo.newBuilder().addUris(jobApplicationUrl).build();

      List<String> addresses = Arrays.asList("1600 Amphitheatre Parkway, Mountain View, CA 94043",
              "111 8th Avenue, New York, NY 10011");

      Job job =
          Job.newBuilder()
              .setCompany(companyId)
              .setRequisitionId(requisitionId)
              .setTitle("Software Developer")
              .setDescription("Develop, maintain the software solutions.")
              .setApplicationInfo(applicationInfo)
              .addAllAddresses(addresses)
              .setLanguageCode("en-US")
              .build();

      CreateJobRequest request =
          CreateJobRequest.newBuilder().setParent(parent.toString()).setJob(job).build();

      Job response = jobServiceClient.createJob(request);
      System.out.printf("Created job: %s\n", response.getName());
    }
  }
}

PHP

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库

require __DIR__ . '/vendor/autoload.php';

use Google\Cloud\Talent\V4beta1\JobServiceClient;
use Google\Cloud\Talent\V4beta1\Job;
use Google\Cloud\Talent\V4beta1\Job_ApplicationInfo;

/**
 * Create Job.
 *
 * @param string $projectId Your Google Cloud Project ID
 * @param string $tenantId  Identifier of the Tenant
 */
function sampleCreateJob($projectId, $tenantId, $companyName, $requisitionId, $title, $description, $jobApplicationUrl, $addressOne, $addressTwo, $languageCode)
{

    $jobServiceClient = new JobServiceClient();

    // $projectId = 'Your Google Cloud Project ID';
    // $tenantId = 'Your Tenant ID (using tenancy is optional)';
    // $companyName = 'Company name, e.g. projects/your-project/companies/company-id';
    // $requisitionId = 'Job requisition ID, aka Posting ID. Unique per job.';
    // $title = 'Software Engineer';
    // $description = 'This is a description of this <i>wonderful</i> job!';
    // $jobApplicationUrl = 'https://www.example.org/job-posting/123';
    // $addressOne = '1600 Amphitheatre Parkway, Mountain View, CA 94043';
    // $addressTwo = '111 8th Avenue, New York, NY 10011';
    // $languageCode = 'en-US';
    $formattedParent = $jobServiceClient->tenantName($projectId, $tenantId);
    $uris = [$jobApplicationUrl];
    $applicationInfo = new Job_ApplicationInfo();
    $applicationInfo->setUris($uris);
    $addresses = [$addressOne, $addressTwo];
    $job = new Job();
    $job->setCompany($companyName);
    $job->setRequisitionId($requisitionId);
    $job->setTitle($title);
    $job->setDescription($description);
    $job->setApplicationInfo($applicationInfo);
    $job->setAddresses($addresses);
    $job->setLanguageCode($languageCode);

    try {
        $response = $jobServiceClient->createJob($formattedParent, $job);
        printf('Created job: %s'.PHP_EOL, $response->getName());
    } finally {
        $jobServiceClient->close();
    }

}

Ruby

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库


# Create Job
#
# @param project_id {String} Your Google Cloud Project ID
# @param tenant_id {String} Identifier of the Tenant
def sample_create_job project_id, tenant_id, company_name, requisition_id, title, description, job_application_url, address_one, address_two, language_code
  # Instantiate a client
  job_client = Google::Cloud::Talent::JobService.new version: :v4beta1

  # project_id = "Your Google Cloud Project ID"
  # tenant_id = "Your Tenant ID (using tenancy is optional)"
  # company_name = "Company name, e.g. projects/your-project/companies/company-id"
  # requisition_id = "Job requisition ID, aka Posting ID. Unique per job."
  # title = "Software Engineer"
  # description = "This is a description of this <i>wonderful</i> job!"
  # job_application_url = "https://www.example.org/job-posting/123"
  # address_one = "1600 Amphitheatre Parkway, Mountain View, CA 94043"
  # address_two = "111 8th Avenue, New York, NY 10011"
  # language_code = "en-US"
  formatted_parent = job_client.class.tenant_path(project_id, tenant_id)
  uris = [job_application_url]
  application_info = { uris: uris }
  addresses = [address_one, address_two]
  job = {
    company: company_name,
    requisition_id: requisition_id,
    title: title,
    description: description,
    application_info: application_info,
    addresses: addresses,
    language_code: language_code
  }

  response = job_client.create_job(formatted_parent, job)
  puts "Created job: #{response.name}"
end

C#

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库

public static object CreateJob(string projectId, string tenantId, string companyId, string requisitionId, string jobApplicationUrl)
{
    JobServiceClient jobServiceClient = JobServiceClient.Create();
    TenantName tenantName = TenantName.FromProjectTenant(projectId, tenantId);

    ApplicationInfo applicationInfo = new ApplicationInfo();
    applicationInfo.Uris.Add(jobApplicationUrl);

    Job job = new Job
    {
        Company = companyId,
        RequisitionId = requisitionId,
        Title = "Software Developer",
        Description = "Develop, maintain the software solutions.",
        ApplicationInfo = applicationInfo,
        LanguageCode = "en-US"
    };
    string[] addresses = { "1600 Amphitheatre Parkway, Mountain View, CA 94043", "111 8th Avenue, New York, NY 10011" };
    job.Addresses.Add(addresses);

    CreateJobRequest request = new CreateJobRequest
    {
        ParentAsTenantName = tenantName,
        Job = job
    };

    Job response = jobServiceClient.CreateJob(request);

    Console.WriteLine($"Created Job: {response.Name}");
    return 0;
}

必填字段

创建和更新招聘信息期间必须填写以下字段:

  • companyName:拥有该职位的公司的资源名称,例如 companyName=\"projects/{ProjectId}/companies/{CompanyId}\"

  • requisitionId:雇用信息 ID(也称为信息 ID)是您指定用于标识职位的值。您可以使用此字段来标识客户和跟踪雇用信息。允许的字符数上限为 225。

    招聘信息的唯一性是通过结合使用 requisitionIDcompanyName 和地点来确定的。如果使用这些属性的特定键创建职位,则该键将存储在 Cloud Talent Solution 索引中。在该职位删除之前,无法使用这些相同的字段创建其他职位。

  • title:职位名称,例如“软件工程师”。允许的最大字符数为 500。

    为了解决因职位名称不标准而导致搜索结果遗漏的问题,Cloud Talent Solution 会利用所有职位字段来了解职位的背景信息,并在内部存储一个“清理版”的职位名称。在向服务发送搜索请求时,系统也会清理搜索查询,并使用本体将清理后的查询映射到相关的清理版职位。

  • description:职位的描述,通常包括对公司的多段描述和相关信息。对于职位对象,还提供了单独的字段,如职责、资质和其他职位特性等。建议使用这些单独的字段。

    此字段接受并清理 HTML 输入,也接受粗体、斜体、有序列表和无序列表标识标记。 允许的最大字符数为 100000。

如下所示:

  • applicationInfo.uris:申请页面的网址。

  • applicationInfo.emails:接收简历或申请的电子邮件地址。

  • applicationInfo.instruction:应用说明,例如“将应用邮寄到...”。此字段会接受并清理 HTML 输入,也接受粗体、斜体、有序列表和无序列表标识标记。允许的字符数上限为 3,000。

常用字段

  • postingExpireTime:招聘信息到期的时间,以时间戳为准。到期后,职位将被标记为已过期,到期的职位不会出现在搜索结果中。 此日期应早于世界协调时间 (UTC) 时区的 2100/12/31。 无效日期(例如过去的日期)将被忽略。 招聘信息的默认到期日期是创建后的 30 天,采用世界协调时间 (UTC) 时区。

    在招聘信息到期后的 60 天内,仍然可以通过 GET 运算符检索其内容。60 天截止日期之后,便无法再通过 GET 操作检索到该招聘信息。

  • addresses:工作地点。建议提供雇用地点的完整街道地址,以获得更好的职位搜索结果,包括按通勤时间搜索职位。允许的字符数上限为 500。如需详细了解 addresses,请参阅下面的最佳做法部分。

  • promotionValue:设置大于 0 的值会将此职位定义为“精选职位”,此类职位仅在类型为 FEATURED_JOBS 的搜索中返回。返回的值越大,该职位在精选职位搜索结果中的位置就越靠前。如需了解详情,请参阅精选职位

使用自定义职位字段

Cloud Talent Solution 包含多个内置于其 API 架构中的职位字段。但是,您仍然可能需要一些开箱即用选项中不存在的其他字段。虽然我们建议您尽可能使用开箱即用的字段,但 Cloud Talent Solution 还是为职位提供了一些 customAttributes 字段。这些字段可能可以过滤,也可能不可过滤。如需了解详情,请参阅 customAttributes 文档。

  • customAttributes:此字段最多可存储 100 个自定义属性,用于存储职位的自定义数据。可以使用指定 jobQuery 字段的搜索请求来过滤这些字段。此外,任何一个字段都可以在 companykeywordSearchableJobCustomAttributes 属性中设置,以便在搜索字词与 keywordSearchableJobCustomAttributes 中的任何字段完全匹配时,返回所有包含此匹配项的职位。

以下代码示例显示了如何使用 customAttribute 创建职位:

Go

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	"github.com/gofrs/uuid"
	talentpb "google.golang.org/genproto/googleapis/cloud/talent/v4beta1"
	money "google.golang.org/genproto/googleapis/type/money"
)

// createJobWithCustomAttributes creates a job with custom attributes.
func createJobWithCustomAttributes(w io.Writer, projectID, companyID, jobTitle string) (*talentpb.Job, error) {
	ctx := context.Background()

	// Initialize a job service client.
	c, err := talent.NewJobClient(ctx)
	if err != nil {
		return nil, fmt.Errorf("talent.NewJobClient: %v", err)
	}

	// requisitionID shoud be the unique ID in your system
	requisitionID := fmt.Sprintf("job-with-custom-attribute-%s", uuid.Must(uuid.NewV4()).String())
	jobToCreate := &talentpb.Job{
		Company:       fmt.Sprintf("projects/%s/companies/%s", projectID, companyID),
		RequisitionId: requisitionID,
		Title:         jobTitle,
		ApplicationInfo: &talentpb.Job_ApplicationInfo{
			Uris: []string{"https://googlesample.com/career"},
		},
		Description:     "Design, devolop, test, deploy, maintain and improve software.",
		LanguageCode:    "en-US",
		PromotionValue:  2,
		EmploymentTypes: []talentpb.EmploymentType{talentpb.EmploymentType_FULL_TIME},
		Addresses:       []string{"Mountain View, CA"},
		CustomAttributes: map[string]*talentpb.CustomAttribute{
			"someFieldString": {
				Filterable:   true,
				StringValues: []string{"someStrVal"},
			},
			"someFieldLong": {
				Filterable: true,
				LongValues: []int64{900},
			},
		},
		CompensationInfo: &talentpb.CompensationInfo{
			Entries: []*talentpb.CompensationInfo_CompensationEntry{
				{
					Type: talentpb.CompensationInfo_BASE,
					Unit: talentpb.CompensationInfo_HOURLY,
					CompensationAmount: &talentpb.CompensationInfo_CompensationEntry_Amount{
						Amount: &money.Money{
							CurrencyCode: "USD",
							Units:        1,
						},
					},
				},
			},
		},
	}

	// Construct a createJob request.
	req := &talentpb.CreateJobRequest{
		Parent: fmt.Sprintf("projects/%s", projectID),
		Job:    jobToCreate,
	}

	resp, err := c.CreateJob(ctx, req)
	if err != nil {
		return nil, fmt.Errorf("CreateJob: %v", err)
	}

	fmt.Fprintf(w, "Created job with custom attributres: %q\n", resp.GetName())
	fmt.Fprintf(w, "Custom long field has value: %v\n", resp.GetCustomAttributes()["someFieldLong"].GetLongValues())

	return resp, nil
}

Java

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库


import com.google.cloud.talent.v4beta1.CreateJobRequest;
import com.google.cloud.talent.v4beta1.CustomAttribute;
import com.google.cloud.talent.v4beta1.Job;
import com.google.cloud.talent.v4beta1.JobServiceClient;
import com.google.cloud.talent.v4beta1.TenantName;
import java.io.IOException;

public class JobSearchCreateJobCustomAttributes {

  public static void createJob() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    String companyId = "your-company-id";
    String requisitionId = "your-unique-req-id";
    createJob(projectId, tenantId, companyId, requisitionId);
  }

  // Create Job with Custom Attributes.
  public static void createJob(
          String projectId,
          String tenantId,
          String companyId,
          String requisitionId)
          throws IOException {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
      TenantName parent = TenantName.of(projectId, tenantId);

      // Custom attribute can be string or numeric value, and can be filtered in search queries.
      // https://cloud.google.com/talent-solution/job-search/docs/custom-attributes
      CustomAttribute customAttribute = CustomAttribute.newBuilder()
              .addStringValues("Internship")
              .addStringValues("Apprenticeship")
              .setFilterable(true)
              .build();

      Job job =
              Job.newBuilder()
                      .setCompany(companyId)
                      .setTitle("Software Developer I")
                      .setDescription("This is a description of this <i>wonderful</i> job!")
                      .putCustomAttributes("FOR_STUDENTS", customAttribute)
                      .setRequisitionId(requisitionId)
                      .setLanguageCode("en-US")
                      .build();

      CreateJobRequest request =
              CreateJobRequest.newBuilder().setParent(parent.toString()).setJob(job).build();
      Job response = jobServiceClient.createJob(request);
      System.out.printf("Created job: %s\n", response.getName());
    }
  }
}

PHP

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库

require __DIR__ . '/vendor/autoload.php';

use Google\Cloud\Talent\V4beta1\JobServiceClient;
use Google\Cloud\Talent\V4beta1\Job;

/**
 * Create Job with Custom Attributes.
 *
 * @param string $projectId Your Google Cloud Project ID
 * @param string $tenantId  Identifier of the Tenantd
 */
function sampleCreateJob($projectId, $tenantId, $companyName, $requisitionId, $languageCode)
{

    $jobServiceClient = new JobServiceClient();

    // $projectId = 'Your Google Cloud Project ID';
    // $tenantId = 'Your Tenant ID (using tenancy is optional)';
    // $companyName = 'Company name, e.g. projects/your-project/companies/company-id';
    // $requisitionId = 'Job requisition ID, aka Posting ID. Unique per job.';
    // $languageCode = 'en-US';
    $formattedParent = $jobServiceClient->tenantName($projectId, $tenantId);
    $job = new Job();
    $job->setCompany($companyName);
    $job->setRequisitionId($requisitionId);
    $job->setLanguageCode($languageCode);

    try {
        $response = $jobServiceClient->createJob($formattedParent, $job);
        printf('Created job: %s'.PHP_EOL, $response->getName());
    } finally {
        $jobServiceClient->close();
    }

}

Ruby

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库


# Create Job with Custom Attributes
#
# @param project_id {String} Your Google Cloud Project ID
# @param tenant_id {String} Identifier of the Tenantd
def sample_create_job project_id, tenant_id, company_name, requisition_id, language_code
  # Instantiate a client
  job_client = Google::Cloud::Talent::JobService.new version: :v4beta1

  # project_id = "Your Google Cloud Project ID"
  # tenant_id = "Your Tenant ID (using tenancy is optional)"
  # company_name = "Company name, e.g. projects/your-project/companies/company-id"
  # requisition_id = "Job requisition ID, aka Posting ID. Unique per job."
  # language_code = "en-US"
  formatted_parent = job_client.class.tenant_path(project_id, tenant_id)
  job = {
    company: company_name,
    requisition_id: requisition_id,
    language_code: language_code
  }

  response = job_client.create_job(formatted_parent, job)
  puts "Created job: #{response.name}"
end

C#

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库

public static object CreateJobCustomAttributes(string projectId, string tenantId, string companyId, string requisitionId)
{
    JobServiceClient jobServiceClient = JobServiceClient.Create();
    TenantName tenantName = TenantName.FromProjectTenant(projectId, tenantId);

    // Custom attribute can be string or numeric value, and can be filtered in search queries.
    // https://cloud.google.com/talent-solution/job-search/docs/custom-attributes
    CustomAttribute customAttributes = new CustomAttribute
    {
        Filterable = true
    };
    customAttributes.StringValues.Add("Internship");
    customAttributes.StringValues.Add("Intern");
    customAttributes.StringValues.Add("Apprenticeship");

    Job job = new Job
    {
        Company = companyId,
        RequisitionId = requisitionId,
        Title = "Software Developer I",
        Description = "This is a description of this <i>wonderful</i> job!",
        LanguageCode = "en-US"
    };
    job.CustomAttributes.Add("FOR_STUDENTS", customAttributes);

    CreateJobRequest request = new CreateJobRequest
    {
        ParentAsTenantName = tenantName,
        Job = job
    };

    Job response = jobServiceClient.CreateJob(request);

    Console.WriteLine($"Created Job: {response.Name}");
    return 0;
}

检索职位

Go

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	talentpb "google.golang.org/genproto/googleapis/cloud/talent/v4beta1"
)

// getJob gets an existing job by its resource name.
func getJob(w io.Writer, projectID, jobID string) (*talentpb.Job, error) {
	ctx := context.Background()

	// Initialize a jobService client.
	c, err := talent.NewJobClient(ctx)
	if err != nil {
		fmt.Printf("talent.NewJobClient: %v\n", err)
		return nil, err
	}

	// Construct a getJob request.
	jobName := fmt.Sprintf("projects/%s/jobs/%s", projectID, jobID)
	req := &talentpb.GetJobRequest{
		// The resource name of the job to retrieve.
		// The format is "projects/{project_id}/jobs/{job_id}".
		Name: jobName,
	}

	resp, err := c.GetJob(ctx, req)
	if err != nil {
		fmt.Printf("Failed to get job %s: %v\n", jobName, err)
		return nil, err
	}

	fmt.Fprintf(w, "Job: %q\n", resp.GetName())
	fmt.Fprintf(w, "Job title: %v\n", resp.GetTitle())

	return resp, err
}

Java

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库


import com.google.cloud.talent.v4beta1.GetJobRequest;
import com.google.cloud.talent.v4beta1.Job;
import com.google.cloud.talent.v4beta1.JobName;
import com.google.cloud.talent.v4beta1.JobServiceClient;
import java.io.IOException;

public class JobSearchGetJob {

  public static void getJob() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    String jobId = "your-job-id";
    getJob(projectId, tenantId, jobId);
  }

  // Get Job.
  public static void getJob(String projectId, String tenantId, String jobId) throws IOException {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
      JobName name = JobName.ofProjectTenantJobName(projectId, tenantId, jobId);

      GetJobRequest request = GetJobRequest.newBuilder().setName(name.toString()).build();

      Job response = jobServiceClient.getJob(request);
      System.out.printf("Job name: %s\n", response.getName());
      System.out.printf("Requisition ID: %s\n", response.getRequisitionId());
      System.out.printf("Title: %s\n", response.getTitle());
      System.out.printf("Description: %s\n", response.getDescription());
      System.out.printf("Posting language: %s\n", response.getLanguageCode());
      for (String address : response.getAddressesList()) {
        System.out.printf("Address: %s\n", address);
      }
      for (String email : response.getApplicationInfo().getEmailsList()) {
        System.out.printf("Email: %s\n", email);
      }
      for (String websiteUri : response.getApplicationInfo().getUrisList()) {
        System.out.printf("Website: %s\n", websiteUri);
      }
    }
  }
}

PHP

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库

require __DIR__ . '/vendor/autoload.php';

use Google\Cloud\Talent\V4beta1\JobServiceClient;

/** Get Job */
function sampleGetJob($projectId, $tenantId, $jobId)
{

    $jobServiceClient = new JobServiceClient();

    // $projectId = 'Your Google Cloud Project ID';
    // $tenantId = 'Your Tenant ID (using tenancy is optional)';
    // $jobId = 'Job ID';
    $formattedName = $jobServiceClient->jobName($projectId, $tenantId, $jobId);

    try {
        $response = $jobServiceClient->getJob($formattedName);
        printf('Job name: %s'.PHP_EOL, $response->getName());
        printf('Requisition ID: %s'.PHP_EOL, $response->getRequisitionId());
        printf('Title: %s'.PHP_EOL, $response->getTitle());
        printf('Description: %s'.PHP_EOL, $response->getDescription());
        printf('Posting language: %s'.PHP_EOL, $response->getLanguageCode());
        foreach ($response->getAddresses() as $address) {
            printf('Address: %s'.PHP_EOL, $address);
        }
        foreach ($response->getApplicationInfo()->getEmails() as $email) {
            printf('Email: %s'.PHP_EOL, $email);
        }
        foreach ($response->getApplicationInfo()->getUris() as $websiteUri) {
            printf('Website: %s'.PHP_EOL, $websiteUri);
        }
    } finally {
        $jobServiceClient->close();
    }

}

Ruby

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库


# Get Job
def sample_get_job project_id, tenant_id, job_id
  # Instantiate a client
  job_client = Google::Cloud::Talent::JobService.new version: :v4beta1

  # project_id = "Your Google Cloud Project ID"
  # tenant_id = "Your Tenant ID (using tenancy is optional)"
  # job_id = "Job ID"
  formatted_name = job_client.class.job_path(project_id, tenant_id, job_id)

  response = job_client.get_job(formatted_name)
  puts "Job name: #{response.name}"
  puts "Requisition ID: #{response.requisition_id}"
  puts "Title: #{response.title}"
  puts "Description: #{response.description}"
  puts "Posting language: #{response.language_code}"
  response.addresses.each do |address|
    puts "Address: #{address}"
  end
  response.application_info.emails.each do |email|
    puts "Email: #{email}"
  end
  response.application_info.uris.each do |website_uri|
    puts "Website: #{website_uri}"
  end
end

C#

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库

public static object GetJob(string projectId, string tenantId, string jobId)
{
    JobServiceClient jobServiceClient = JobServiceClient.Create();
    JobName jobName = JobName.FromProjectTenantJob(projectId, tenantId, jobId);
    GetJobRequest request = new GetJobRequest
    {
        JobName = jobName
    };
    var response = jobServiceClient.GetJob(request);

    Console.WriteLine($"Job name: {response.Name}");
    Console.WriteLine($"Requisition ID: {response.RequisitionId}");
    Console.WriteLine($"Title: {response.Title}");
    Console.WriteLine($"Description: {response.Description}");
    Console.WriteLine($"Posting language: {response.LanguageCode}");
    foreach (string address in response.Addresses)
    {
        Console.WriteLine($"Address: {address}");
    }
    foreach (string email in response.ApplicationInfo.Emails)
    {
        Console.WriteLine($"Email: {email}");
    }
    foreach (string websiteUri in response.ApplicationInfo.Uris)
    {
        Console.WriteLine($"Website: {websiteUri}");
    }
    return 0;
}

列出作业

Go

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	"google.golang.org/api/iterator"
	talentpb "google.golang.org/genproto/googleapis/cloud/talent/v4beta1"
)

// listJobs lists jobs with a filter, for example
// `companyName="projects/my-project/companies/123"`.
func listJobs(w io.Writer, projectID, companyID string) error {
	ctx := context.Background()

	// Initialize a jobService client.
	c, err := talent.NewJobClient(ctx)
	if err != nil {
		fmt.Printf("talent.NewJobClient: %v\n", err)
		return err
	}

	// Construct a listJobs request.
	companyName := fmt.Sprintf("projects/%s/companies/%s", projectID, companyID)
	req := &talentpb.ListJobsRequest{
		Parent: "projects/" + projectID,
		Filter: fmt.Sprintf("companyName=%q", companyName),
	}

	it := c.ListJobs(ctx, req)

	for {
		resp, err := it.Next()
		if err == iterator.Done {
			return nil
		}
		if err != nil {
			fmt.Printf("it.Next: %v\n", err)
			return err
		}
		fmt.Fprintf(w, "Listing job: %v\n", resp.GetName())
		fmt.Fprintf(w, "Job title: %v\n", resp.GetTitle())
	}
}

Java

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库


import com.google.cloud.talent.v4beta1.Job;
import com.google.cloud.talent.v4beta1.JobServiceClient;
import com.google.cloud.talent.v4beta1.ListJobsRequest;
import com.google.cloud.talent.v4beta1.TenantName;
import java.io.IOException;

public class JobSearchListJobs {

  public static void listJobs() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    String query = "count(base_compensation, [bucket(12, 20)])";
    listJobs(projectId, tenantId, query);
  }

  // Search Jobs with histogram queries.
  public static void listJobs(String projectId, String tenantId, String filter) throws IOException {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
      TenantName parent = TenantName.of(projectId, tenantId);
      ListJobsRequest request =
          ListJobsRequest.newBuilder().setParent(parent.toString()).setFilter(filter).build();
      for (Job responseItem : jobServiceClient.listJobs(request).iterateAll()) {
        System.out.printf("Job name: %s\n", responseItem.getName());
        System.out.printf("Job requisition ID: %s\n", responseItem.getRequisitionId());
        System.out.printf("Job title: %s\n", responseItem.getTitle());
        System.out.printf("Job description: %s\n", responseItem.getDescription());
      }
    }
  }
}

PHP

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库

require __DIR__ . '/vendor/autoload.php';

use Google\Cloud\Talent\V4beta1\JobServiceClient;

/**
 * List Jobs.
 *
 * @param string $projectId Your Google Cloud Project ID
 * @param string $tenantId  Identifier of the Tenant
 */
function sampleListJobs($projectId, $tenantId, $filter)
{

    $jobServiceClient = new JobServiceClient();

    // $projectId = 'Your Google Cloud Project ID';
    // $tenantId = 'Your Tenant ID (using tenancy is optional)';
    // $filter = 'companyName=projects/my-project/companies/company-id';
    $formattedParent = $jobServiceClient->tenantName($projectId, $tenantId);

    try {
        // Iterate through all elements
        $pagedResponse = $jobServiceClient->listJobs($formattedParent, $filter);
        foreach ($pagedResponse->iterateAllElements() as $responseItem) {
            printf('Job name: %s'.PHP_EOL, $responseItem->getName());
            printf('Job requisition ID: %s'.PHP_EOL, $responseItem->getRequisitionId());
            printf('Job title: %s'.PHP_EOL, $responseItem->getTitle());
            printf('Job description: %s'.PHP_EOL, $responseItem->getDescription());
        }
    } finally {
        $jobServiceClient->close();
    }

}

Ruby

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库


# List Jobs
#
# @param project_id {String} Your Google Cloud Project ID
# @param tenant_id {String} Identifier of the Tenant
def sample_list_jobs project_id, tenant_id, filter
  # Instantiate a client
  job_client = Google::Cloud::Talent::JobService.new version: :v4beta1

  # project_id = "Your Google Cloud Project ID"
  # tenant_id = "Your Tenant ID (using tenancy is optional)"
  # filter = "companyName=projects/my-project/companies/company-id"
  formatted_parent = job_client.class.tenant_path(project_id, tenant_id)

  # Iterate over all results.
  job_client.list_jobs(formatted_parent, filter).each do |element|
    puts "Job name: #{element.name}"
    puts "Job requisition ID: #{element.requisition_id}"
    puts "Job title: #{element.title}"
    puts "Job description: #{element.description}"
  end
end

C#

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库

public static object ListJobs(string projectId, string tenantId, string filter)
{
    JobServiceClient jobServiceClient = JobServiceClient.Create();

    TenantName tenantName = TenantName.FromProjectTenant(projectId, tenantId);
    ListJobsRequest request = new ListJobsRequest
    {
        ParentAsTenantName = tenantName,
        Filter = filter
    };
    PagedEnumerable<ListJobsResponse, Job> jobs = jobServiceClient.ListJobs(request);

    foreach (var job in jobs)
    {
        Console.WriteLine($"Job name: {job.Name}");
        Console.WriteLine($"Job requisition ID: {job.RequisitionId}");
        Console.WriteLine($"Job title: {job.Title}");
        Console.WriteLine($"Job description: {job.Description}");
    }
    return 0;
}

删除作业

Go

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	talentpb "google.golang.org/genproto/googleapis/cloud/talent/v4beta1"
)

// deleteJob deletes an existing job by its resource name.
func deleteJob(w io.Writer, projectID, jobID string) error {
	ctx := context.Background()

	// Initialize a jobService client.
	c, err := talent.NewJobClient(ctx)
	if err != nil {
		fmt.Printf("talent.NewJobClient: %v\n", err)
		return err
	}

	// Construct a deleteJob request.
	jobName := fmt.Sprintf("projects/%s/jobs/%s", projectID, jobID)
	req := &talentpb.DeleteJobRequest{
		// The resource name of the job to be deleted.
		// The format is "projects/{project_id}/jobs/{job_id}".
		Name: jobName,
	}

	if err := c.DeleteJob(ctx, req); err != nil {
		fmt.Printf("Delete(%s): %v\n", jobName, err)
		return err
	}

	fmt.Printf("Deleted job: %q\n", jobName)

	return err
}

Java

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库


import com.google.cloud.talent.v4beta1.DeleteJobRequest;
import com.google.cloud.talent.v4beta1.JobName;
import com.google.cloud.talent.v4beta1.JobServiceClient;
import java.io.IOException;

public class JobSearchDeleteJob {

  public static void deleteJob() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    String jobId = "your-job-id";
    deleteJob(projectId, tenantId, jobId);
  }

  // Delete Job.
  public static void deleteJob(String projectId, String tenantId, String jobId) throws IOException {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
      JobName name = JobName.ofProjectTenantJobName(projectId, tenantId, jobId);

      DeleteJobRequest request = DeleteJobRequest.newBuilder().setName(name.toString()).build();

      jobServiceClient.deleteJob(request);
      System.out.println("Deleted job.");
    }
  }
}

PHP

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库

require __DIR__ . '/vendor/autoload.php';

use Google\Cloud\Talent\V4beta1\JobServiceClient;

/** Delete Job */
function sampleDeleteJob($projectId, $tenantId, $jobId)
{

    $jobServiceClient = new JobServiceClient();

    // $projectId = 'Your Google Cloud Project ID';
    // $tenantId = 'Your Tenant ID (using tenancy is optional)';
    // $jobId = 'Company ID';
    $formattedName = $jobServiceClient->jobName($projectId, $tenantId, $jobId);

    try {
        $jobServiceClient->deleteJob($formattedName);
        printf('Deleted job.'.PHP_EOL);
    } finally {
        $jobServiceClient->close();
    }

}

Ruby

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库


# Delete Job
def sample_delete_job project_id, tenant_id, job_id
  # Instantiate a client
  job_client = Google::Cloud::Talent::JobService.new version: :v4beta1

  # project_id = "Your Google Cloud Project ID"
  # tenant_id = "Your Tenant ID (using tenancy is optional)"
  # job_id = "Company ID"
  formatted_name = job_client.class.job_path(project_id, tenant_id, job_id)

  job_client.delete_job(formatted_name)

  puts "Deleted job."
end

C#

如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库

public static object DeleteJob(string projectId, string tenantId, string jobId)
{
    JobServiceClient jobServiceClient = JobServiceClient.Create();
    JobName jobName = JobName.FromProjectTenantJob(projectId, tenantId, jobId);
    DeleteJobRequest request = new DeleteJobRequest
    {
        JobName = jobName
    };

    jobServiceClient.DeleteJob(request);

    Console.WriteLine("Deleted Job.");
    return 0;
}

最佳做法

地点字段

我们建议您尽可能在 addresses 字段中提供职位的街道地址。这有助于位置检测和相关性匹配。如果无法提供街道地址,请输入尽可能多的信息。 最高支持国家/地区级别的地址。 不支持区域名称(例如“太平洋西北地区”)。

Cloud Talent Solution 使用 addresses 字段中的数据填充(仅限输出)derivedInfo.locations 字段。如果未提供完整地址,则服务会通过其他信息(例如公司名称)来确定是否能为招聘信息帖子推断出更完整的地址。

例如,如果软件职位的地点被指定为 Mountain View,并且与该职位相关联的公司是 Google,该服务会查找 company 对象,以查看在 headquartersAddress 字段中是否提供了更好的街道地址,以及该街道地址是否与招聘信息位于同一个城市。如果是,服务会了解,职位“有可能”位于该街道地址并适当填充 derivedInfo.locations 字段。

如果公司地址数据不可用,服务会结合专有知识和招聘信息/公司信息来填写 derivedInfo.locations 字段。

由于 derivedInfo.locations 值是尽力猜测出的结果,因此在显示职位地址时,您可能需要使用 derivedInfo.locations 数据或 addresses 字段。

招聘信息帖子的关联位置不得超过 50 个。如果超过这个限制,您可以将招聘信息拆分为多个,每个分配一个唯一的 requisitionid(例如“ReqA”、“ReqA-1”、“ReqA-2”等等)。系统不允许多个招聘信息使用相同的 requisitionIdcompanyNamelanguageCode。如果必须保留原始 requisitionId,则应使用 CustomAttribute 进行存储。建议您将距离最近的位置组合归入同一招聘信息,以提供更好的搜索体验。

支持的地址

Cloud Talent Solution 接受 Google Maps Geocoding API 可识别的任何地址(在 formattedAddress 字段中)。如果您尝试使用无法识别的地址创建职位或执行搜索,服务会返回 400 错误。

如果 Google Maps Geocoding API 中所列的办公地址不正确,请提交错误以便相关人员更正。更正的地址可能需要 5 天才能生效。

地址自动填充

Cloud Talent Solution 不提供位置的自动填充建议。 使用 Google Maps Places API 或其他类似的位置服务来填充自动填充建议。

全州、全国和远程办公的职位

可以使用 postingRegion 字段将职位指定为全州职位、全国职位或远程办公职位。

  • 如果招聘信息中的州/省/国家/地区涵盖搜索指定的位置,系统将返回 ADMINISTRATIVE_AREANATION 职位。例如,如果搜索时将 LocationFilter 指定为“西雅图”,则返回结果中也会包含工作地点为“美国华盛顿州”的 ADMINISTRATIVE_AREA 职位。

  • 所有与位置相关的搜索都会返回 TELECOMMUTE 职位,但这些职位会被视为相关性较低。可以通过在搜索的 LocationFilter 中将 telecommutePreference 标志设置为 TELECOMMUTE_ALLOWED 来搜索这类职位。