自定义属性

Cloud Talent Solution 以开箱即用的方式提供了多种不同的职位属性,可以满足各种客户的需求。为了通过 Cloud Talent Solution 实现最佳性能,强烈建议您尽可能使用开箱即用的字段。

此外,Cloud Talent Solution 还提供用于存储常规信息的自定义属性。自定义属性用于提供更高的灵活性,以允许客户支持其业务逻辑。自定义属性会存储字符串或数值信息,用户可以设置适当的过滤器对搜索查询进行过滤。

自定义属性功能

  • 定义您自己的自定义字段名称:定义一则招聘信息的特定属性的名称。根据需要将此属性设置为可过滤或不可过滤。通常,如果界面需要 Cloud Talent Solution 未以开箱即用方式提供的可过滤属性,则可以使用 customAttribute 提供适当的过滤。
  • (不)区分大小写的搜索:各搜索请求可以指定针对所有自定义属性发起的搜索是否区分大小写。
  • 基于范围的过滤customAttribute 搜索过滤器可以过滤一系列指定的数值之间的招聘信息。例如,如果给定的 customAttribute 字段用于存储招聘信息的最低 GPA 要求,则 customAttribute 搜索过滤器可用于返回符合在特定最小 GPA 范围内、大于最小 GPA 值、小于最小 GPA 值等条件的招聘信息。
  • 跨字段过滤customAttribute 还为 Cloud Talent Solution 客户提供了通过定义表达式来过滤自定义属性组合的功能。例如,一家客户的业务逻辑表明,他们只想寻找帮助办理签证或支持远程办公的职位。客户将这两个字段存储在不同的 customAttribute 中。然后,客户可以使用一个定义必要逻辑的表达式来指定搜索过滤器。该系统仅支持 3 级嵌套表达式。

  • 关键字特定搜索:在相关公司的 keywordSearchableCustomAttributes 中指定特定的 customAttribute,以确保指定 customAttribute 中包含一个值的搜索请求返回 customAttribute 中包含此值的招聘信息。

  • 基于 SQL 的搜索customAttribute 允许您在搜索请求中定义布尔值式的表达式。Cloud Talent Solution 会自动解析这些表达式,将过滤器应用于搜索请求,并相应地返回结果。该系统仅允许 3 级嵌套式布尔值表达式,最多允许 2000 个字符。

  • 定义自定义直方图存储分区:自定义属性允许 Cloud Talent Solution 设置自定义存储分区,以计算直方图。 例如,您可以使用 customAttribute 存储最小 GPA 信息,然后根据此字段创建直方图。您可以进一步创建 3.0-3.5、3.51-4.0 等范围内的存储分区,将所有最小 GPA 分组到这些存储分区之内。

使用自定义属性

使用 customAttribute 字段(可与数值或字符串值一起使用)创建新招聘信息:

Go

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;
}

默认情况下,searchJobssearchJobsForAlert 端点仅搜索开箱即用的字段。如果还需要搜索 customAttribute 字段,请使用 keywordSearchableJobCustomAttributes 字段来定义要搜索的自定义属性列表。

例如,如果招聘人员希望使用 customAttribute"customRequisitions"来存储特定雇主职位的雇用 ID,那么可以将 keywordSearchableJobCustomAttributes 设置为包含此字段,此时招聘人员对“ABC123”执行常规搜索时即可返回 customAttribute"customRequisitions"的值设置为“ABC123”的所有招聘信息。