招聘信息基础知识

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

您可以使用 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.v4.CreateJobRequest;
import com.google.cloud.talent.v4.Job;
import com.google.cloud.talent.v4.JobServiceClient;
import com.google.cloud.talent.v4.TenantName;
import java.io.IOException;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;

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";
    // String projectId = "me-qa-1";
    // String tenantId = "8ed97629-27ee-4215-909b-18cfe3b7e8e3";
    // String companyId = "05317758-b30e-4b26-a57d-d9e54e4cccd8";
    // String requisitionId = "test-requisitionid-1";
    // String jobApplicationUrl = "http://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 {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    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");

      // By default, job will expire in 30 days.
      // https://cloud.google.com/talent-solution/job-search/docs/jobs
      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.format("Created job: %s%n", response.getName());
    }
  }
}

Node.js

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


const talent = require('@google-cloud/talent').v4;

/**
 * Create Job
 *
 * @param projectId {string} Your Google Cloud Project ID
 * @param tenantId {string} Identifier of the Tenant
 */
function sampleCreateJob(
  projectId,
  tenantId,
  companyName,
  requisitionId,
  title,
  description,
  jobApplicationUrl,
  addressOne,
  addressTwo,
  languageCode
) {
  const client = new talent.JobServiceClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const companyName = 'Company name, e.g. projects/your-project/companies/company-id';
  // const requisitionId = 'Job requisition ID, aka Posting ID. Unique per job.';
  // const title = 'Software Engineer';
  // const description = 'This is a description of this <i>wonderful</i> job!';
  // const jobApplicationUrl = 'https://www.example.org/job-posting/123';
  // const addressOne = '1600 Amphitheatre Parkway, Mountain View, CA 94043';
  // const addressTwo = '111 8th Avenue, New York, NY 10011';
  // const languageCode = 'en-US';
  const formattedParent = client.tenantPath(projectId, tenantId);
  const uris = [jobApplicationUrl];
  const applicationInfo = {
    uris: uris,
  };
  const addresses = [addressOne, addressTwo];
  const job = {
    company: companyName,
    requisitionId: requisitionId,
    title: title,
    description: description,
    applicationInfo: applicationInfo,
    addresses: addresses,
    languageCode: languageCode,
  };
  const request = {
    parent: formattedParent,
    job: job,
  };
  client
    .createJob(request)
    .then(responses => {
      const response = responses[0];
      console.log(`Created job: ${response.name}`);
    })
    .catch(err => {
      console.error(err);
    });
}

Python

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


from google.cloud import talent
import six

def create_job(
    project_id, tenant_id, company_id, requisition_id, job_application_url,
):
    """Create Job"""

    client = talent.JobServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # company_id = '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'

    if isinstance(project_id, six.binary_type):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, six.binary_type):
        tenant_id = tenant_id.decode("utf-8")
    if isinstance(company_id, six.binary_type):
        company_id = company_id.decode("utf-8")
    if isinstance(requisition_id, six.binary_type):
        requisition_id = requisition_id.decode("utf-8")
    if isinstance(job_application_url, six.binary_type):
        job_application_url = job_application_url.decode("utf-8")
    parent = f"projects/{project_id}/tenants/{tenant_id}"
    uris = [job_application_url]
    application_info = {"uris": uris}
    addresses = [
        "1600 Amphitheatre Parkway, Mountain View, CA 94043",
        "111 8th Avenue, New York, NY 10011",
    ]
    job = {
        "company": company_id,
        "requisition_id": requisition_id,
        "title": "Software Developer",
        "description": "Develop, maintain the software solutions.",
        "application_info": application_info,
        "addresses": addresses,
        "language_code": "en-US",
    }

    response = client.create_job(parent=parent, job=job)
    print("Created job: {}".format(response.name))
    return response.name

Ruby

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

require "google/cloud/talent"

# Instantiate a client
job_service = Google::Cloud::Talent.job_service

# project_id = "Your Google Cloud Project ID"
# tenant_id = "Your Tenant ID (using tenancy is required)"
parent = job_service.tenant_path project: project_id, tenant: tenant_id

# job_application_url = "https://www.example.org/job-posting/123"
uris = [job_application_url]
application_info = { uris: uris }

# address = "1600 Amphitheatre Parkway, Mountain View, CA 94043"
addresses = [address]

# 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!"
# language_code = "en-US"
job = {
  company:          company_name,
  requisition_id:   requisition_id,
  title:            title,
  description:      description,
  application_info: application_info,
  addresses:        addresses,
  language_code:    language_code
}

response = job_service.create_job parent: parent, job: job
puts "Created job: #{response.name}"

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.v4.CreateJobRequest;
import com.google.cloud.talent.v4.CustomAttribute;
import com.google.cloud.talent.v4.Job;
import com.google.cloud.talent.v4.JobServiceClient;
import com.google.cloud.talent.v4.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 {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    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());
    }
  }
}

Node.js

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


const talent = require('@google-cloud/talent').v4;

/**
 * Create Job with Custom Attributes
 *
 * @param projectId {string} Your Google Cloud Project ID
 * @param tenantId {string} Identifier of the Tenantd
 */
function sampleCreateJob(
  projectId,
  tenantId,
  companyName,
  requisitionId,
  languageCode
) {
  const client = new talent.JobServiceClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const companyName = 'Company name, e.g. projects/your-project/companies/company-id';
  // const requisitionId = 'Job requisition ID, aka Posting ID. Unique per job.';
  // const languageCode = 'en-US';
  const formattedParent = client.tenantPath(projectId, tenantId);
  const job = {
    company: companyName,
    requisitionId: requisitionId,
    languageCode: languageCode,
  };
  const request = {
    parent: formattedParent,
    job: job,
  };
  client
    .createJob(request)
    .then(responses => {
      const response = responses[0];
      console.log(`Created job: ${response.name}`);
    })
    .catch(err => {
      console.error(err);
    });
}

Python

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


from google.cloud import talent
import six

def create_job(project_id, tenant_id, company_id, requisition_id):
    """Create Job with Custom Attributes"""

    client = talent.JobServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # company_id = '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'

    if isinstance(project_id, six.binary_type):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, six.binary_type):
        tenant_id = tenant_id.decode("utf-8")
    if isinstance(company_id, six.binary_type):
        company_id = company_id.decode("utf-8")

    # 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
    custom_attribute = talent.CustomAttribute()
    custom_attribute.filterable = True
    custom_attribute.string_values.append("Intern")
    custom_attribute.string_values.append("Apprenticeship")

    parent = f"projects/{project_id}/tenants/{tenant_id}"

    job = talent.Job(
        company=company_id,
        title="Software Engineer",
        requisition_id=requisition_id,
        description="This is a description of this job",
        language_code="en-us",
        custom_attributes={"FOR_STUDENTS": custom_attribute}
    )

    response = client.create_job(parent=parent, job=job)
    print(f"Created job: {response.name}")
    return response.name

Ruby

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

require "google/cloud/talent"

# Instantiate a client
job_service = Google::Cloud::Talent.job_service

# project_id = "Your Google Cloud Project ID"
# tenant_id = "Your Tenant ID (using tenancy is required)"
parent = job_service.tenant_path project: project_id, tenant: tenant_id

# title = "Software Engineer"
# description = "This is a description of this <i>wonderful</i> job!"
# 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"
job = {
  title:          title,
  description:    description,
  company:        company_name,
  requisition_id: requisition_id,
  language_code:  language_code
}

response = job_service.create_job parent: parent, job: job
puts "Created job: #{response.name}"

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.v4.GetJobRequest;
import com.google.cloud.talent.v4.Job;
import com.google.cloud.talent.v4.JobName;
import com.google.cloud.talent.v4.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 {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
      JobName name = JobName.of(projectId, tenantId, jobId);

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

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

Node.js

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


const talent = require('@google-cloud/talent').v4;

/** Get Job */
function sampleGetJob(projectId, tenantId, jobId) {
  const client = new talent.JobServiceClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const jobId = 'Job ID';
  const formattedName = client.jobPath(projectId, tenantId, jobId);
  client
    .getJob({name: formattedName})
    .then(responses => {
      const response = responses[0];
      console.log(`Job name: ${response.name}`);
      console.log(`Requisition ID: ${response.requisitionId}`);
      console.log(`Title: ${response.title}`);
      console.log(`Description: ${response.description}`);
      console.log(`Posting language: ${response.languageCode}`);
      for (const address of response.addresses) {
        console.log(`Address: ${address}`);
      }
      for (const email of response.applicationInfo.emails) {
        console.log(`Email: ${email}`);
      }
      for (const websiteUri of response.applicationInfo.uris) {
        console.log(`Website: ${websiteUri}`);
      }
    })
    .catch(err => {
      console.error(err);
    });
}

Python

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


from google.cloud import talent
import six

def get_job(project_id, tenant_id, job_id):
    """Get Job"""

    client = talent.JobServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # job_id = 'Job ID'

    if isinstance(project_id, six.binary_type):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, six.binary_type):
        tenant_id = tenant_id.decode("utf-8")
    if isinstance(job_id, six.binary_type):
        job_id = job_id.decode("utf-8")
    name = client.job_path(project_id, tenant_id, job_id)

    response = client.get_job(name=name)
    print(f"Job name: {response.name}")
    print(f"Requisition ID: {response.requisition_id}")
    print(f"Title: {response.title}")
    print(f"Description: {response.description}")
    print(f"Posting language: {response.language_code}")
    for address in response.addresses:
        print(f"Address: {address}")
    for email in response.application_info.emails:
        print(f"Email: {email}")
    for website_uri in response.application_info.uris:
        print(f"Website: {website_uri}")

Ruby

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

require "google/cloud/talent"

# Instantiate a client
job_service = Google::Cloud::Talent.job_service

# project_id = "Your Google Cloud Project ID"
# tenant_id = "Your Tenant ID (using tenancy is required)"
# job_id = "Job ID"
formatted_name = job_service.job_path project: project_id,
                                      tenant:  tenant_id,
                                      job:     job_id

response = job_service.get_job name: 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

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.v4.Job;
import com.google.cloud.talent.v4.JobServiceClient;
import com.google.cloud.talent.v4.ListJobsRequest;
import com.google.cloud.talent.v4.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 {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    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.format("Job name: %s%n", responseItem.getName());
        System.out.format("Job requisition ID: %s%n", responseItem.getRequisitionId());
        System.out.format("Job title: %s%n", responseItem.getTitle());
        System.out.format("Job description: %s%n", responseItem.getDescription());
      }
    }
  }
}

Node.js

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


const talent = require('@google-cloud/talent').v4;

/**
 * List Jobs
 *
 * @param projectId {string} Your Google Cloud Project ID
 * @param tenantId {string} Identifier of the Tenant
 */
function sampleListJobs(projectId, tenantId, filter) {
  const client = new talent.JobServiceClient();
  // Iterate over all elements.
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const filter = 'companyName=projects/my-project/companies/company-id';
  const formattedParent = client.tenantPath(projectId, tenantId);
  const request = {
    parent: formattedParent,
    filter: filter,
  };

  client
    .listJobs(request)
    .then(responses => {
      const resources = responses[0];
      for (const resource of resources) {
        console.log(`Job name: ${resource.name}`);
        console.log(`Job requisition ID: ${resource.requisitionId}`);
        console.log(`Job title: ${resource.title}`);
        console.log(`Job description: ${resource.description}`);
      }
    })
    .catch(err => {
      console.error(err);
    });
}

Python

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


from google.cloud import talent
import six

def list_jobs(project_id, tenant_id, filter_):
    """List Jobs"""

    client = talent.JobServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # filter_ = 'companyName=projects/my-project/companies/company-id'

    if isinstance(project_id, six.binary_type):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, six.binary_type):
        tenant_id = tenant_id.decode("utf-8")
    if isinstance(filter_, six.binary_type):
        filter_ = filter_.decode("utf-8")
    parent = f"projects/{project_id}/tenants/{tenant_id}"

    # Iterate over all results
    results = []
    for job in client.list_jobs(parent=parent, filter=filter_):
        results.append(job.name)
        print("Job name: {job.name}")
        print("Job requisition ID: {job.requisition_id}")
        print("Job title: {job.title}")
        print("Job description: {job.description}")
    return results

Ruby

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

require "google/cloud/talent"

# Instantiate a client
job_service = Google::Cloud::Talent.job_service

# project_id = "Your Google Cloud Project ID"
# tenant_id = "Your Tenant ID (using tenancy is required)"
formatted_parent = job_service.tenant_path project: project_id, tenant: tenant_id

# Iterate over all results.
# filter = "companyName=\"projects/my-project/companies/company-id\""
job_service.list_jobs(parent: formatted_parent, filter: 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

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.v4.DeleteJobRequest;
import com.google.cloud.talent.v4.JobName;
import com.google.cloud.talent.v4.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 {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
      JobName name = JobName.of(projectId, tenantId, jobId);

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

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

Node.js

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


const talent = require('@google-cloud/talent').v4;

/** Delete Job */
function sampleDeleteJob(projectId, tenantId, jobId) {
  const client = new talent.JobServiceClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const jobId = 'Company ID';
  const formattedName = client.jobPath(projectId, tenantId, jobId);
  client.deleteJob({name: formattedName}).catch(err => {
    console.error(err);
  });
  console.log('Deleted job.');
}

Python

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


from google.cloud import talent
import six

def delete_job(project_id, tenant_id, job_id):
    """Delete Job"""

    client = talent.JobServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # job_id = 'Company ID'

    if isinstance(project_id, six.binary_type):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, six.binary_type):
        tenant_id = tenant_id.decode("utf-8")
    if isinstance(job_id, six.binary_type):
        job_id = job_id.decode("utf-8")
    name = client.job_path(project_id, tenant_id, job_id)

    client.delete_job(name=name)
    print("Deleted job.")

Ruby

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

require "google/cloud/talent"

# Instantiate a client
job_service = Google::Cloud::Talent.job_service

# project_id = "Your Google Cloud Project ID"
# tenant_id = "Your Tenant ID (using tenancy is required)"
# job_id = "Company ID"
formatted_name = job_service.job_path project: project_id,
                                      tenant:  tenant_id,
                                      job:     job_id

job_service.delete_job name: formatted_name

puts "Deleted job."

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 来搜索这类职位。