カスタム属性

Cloud Talent Solution には、さまざまなお客様のニーズに対応するためにすぐに使用できる求人属性が複数用意されています。Cloud Talent Solution が最大のパフォーマンスを発揮できるよう、このすぐに使用可能な項目をできる限り活用することを強くおすすめします。

さらに、Cloud Talent Solution には全般的な情報を保存するカスタム属性も用意されています。カスタム属性を使用すると、お客様のビジネス ロジックに対応するための柔軟性がさらに高まります。カスタム属性には文字列または数値のいずれかの情報が保存され、適切なフィルタを設定することで、カスタム属性を検索クエリのフィルタ対象に設定できます。

カスタム属性機能

  • 独自のカスタム項目名の定義: 求人の特定の属性名を定義します。この属性は、必要に応じてフィルタ可能かフィルタ不可能に設定します。UI でフィルタ可能ファセットが必要な場合、それがすぐに使用できる形で 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 つのブール式のみが許容され、使用できる最大文字数は 2,000 文字です。

  • カスタム ヒストグラム バケットの定義: カスタム属性を使用すると、Cloud Talent Solution のお客様がヒストグラムの計算に使用できるカスタム バケットを設定できます。 たとえば、customAttribute を使用して最低 GPA 情報を保存し、この項目にヒストグラムを作成できます。さらに 3.0 から 3.5、3.51 から 4.0 などのバケットを作成し、それらのバケット内ですべての最低 GPA をグループ化できます。

カスタム属性の使用

customAttribute 項目を使用して新しい求人を作成します(この項目には数値と文字列のどちらも使用できます)。

Go

CTS 用のクライアント ライブラリをインストールして使用する方法については、CTS クライアント ライブラリをご覧ください。 詳細については、CTS Go API のリファレンス ドキュメントをご覧ください。

CTS への認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	"cloud.google.com/go/talent/apiv4beta1/talentpb"
	"github.com/gofrs/uuid"
	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: %w", err)
	}
	defer c.Close()

	// 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: %w", 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

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, bytes):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, bytes):
        tenant_id = tenant_id.decode("utf-8")
    if isinstance(company_id, bytes):
        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

デフォルトでは、searchJobs エンドポイントと searchJobsForAlert エンドポイントの検索対象はすぐに使用できるように用意された項目のみです。customAttribute 項目に対する検索も行う必要がある場合は、keywordSearchableJobCustomAttributes 項目を使用して、検索するカスタム属性のリストを定義します。

たとえば、採用担当者が customAttribute「customRequisitions」を使用して特定の雇用主に特化した求人の求人 ID を保存することを希望する場合、この項目を含むように keywordSearchableJobCustomAttributes を設定することで、この採用担当者が「ABC123」を対象に実施する通常の検索において、customAttribute「customRequisitions」に値「ABC123」が設定されたすべての求人情報が返されます。