自定义属性 (v3)

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 字段(可与数值或字符串值一起使用)创建新招聘信息:

Java

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


/**
 * Generate a job with a custom attribute.
 */
public static Job generateJobWithACustomAttribute(String companyName) {
  // requisition id should be a unique Id in your system.
  String requisitionId =
      "jobWithACustomAttribute:" + String.valueOf(new Random().nextLong());
  ApplicationInfo applicationInfo =
      new ApplicationInfo().setUris(Arrays.asList("http://careers.google.com"));

  // Constructs custom attributes map
  Map<String, CustomAttribute> customAttributes = new HashMap<>();
  customAttributes.put(
      "someFieldName1",
      new CustomAttribute()
          .setStringValues(Arrays.asList("value1"))
          .setFilterable(Boolean.TRUE));
  customAttributes
      .put("someFieldName2",
          new CustomAttribute().setLongValues(Arrays.asList(256L)).setFilterable(true));

  // Creates job with custom attributes
  Job job =
      new Job()
          .setCompanyName(companyName)
          .setRequisitionId(requisitionId)
          .setTitle("Software Engineer")
          .setApplicationInfo(applicationInfo)
          .setDescription("Design, develop, test, deploy, maintain and improve software.")
          .setCustomAttributes(customAttributes);
  System.out.println("Job generated: " + job);
  return job;
}

Python

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

def generate_job_with_custom_attributes(company_name):
    # Requisition id should be a unique Id in your system.
    requisition_id = 'job_with_custom_attributes:' + ''.join(
        random.choice(string.ascii_uppercase + string.digits)
        for _ in range(16))

    job_title = 'Software Engineer'
    application_urls = ['http://careers.google.com']
    description = ('Design, develop, test, deploy, maintain and improve '
                   'software.')

    custom_attributes = {
        'someFieldName1': {
            'string_values': ['value1'],
            'filterable': True
        },
        'someFieldName2': {
            'long_values': [256],
            'filterable': True
        }
    }

    job = {
        'company_name': company_name,
        'requisition_id': requisition_id,
        'title': job_title,
        'application_info': {'uris': application_urls},
        'description': description,
        'custom_attributes': custom_attributes
    }
    print('Job generated: %s' % job)
    return job

C#

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


public static Job GenerateJobWithCustomAttribute(string companyName)
{
    ApplicationInfo applicationInfo = new ApplicationInfo()
    {
        Uris = new List<string>
        {
            "http://careers.google.com"
        }
    };

    CustomAttribute customAttribute = new CustomAttribute();
    customAttribute.StringValues = new List<String>()
    {
        "attribute"
    };

    Dictionary<String, CustomAttribute> customAttributes = new Dictionary<string, CustomAttribute>
    {
        { "custom_attribute", customAttribute }
    };

    Job customJob = new Job()
    {
        Title = "Software Engineer",
        RequisitionId = generateRandom(),
        Description = "My Job Description Here",
        CompanyName = myCompany.Name,
        ApplicationInfo = applicationInfo,
        CustomAttributes = customAttributes
    };

    Console.WriteLine("Created custom job: " + customJob.Title);
    return customJob;
}

Go

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


// constructJobWithCustomAttributes constructs a job with custom attributes.
func constructJobWithCustomAttributes(companyName string, jobTitle string) *talent.Job {
	// requisitionID shoud be the unique ID in your system
	requisitionID := fmt.Sprintf("job-with-custom-attribute-%d", time.Now().UnixNano())

	job := &talent.Job{
		RequisitionId: requisitionID,
		Title:         jobTitle,
		CompanyName:   companyName,
		ApplicationInfo: &talent.ApplicationInfo{
			Uris: []string{"https://googlesample.com/career"},
		},
		Description: "Design, devolop, test, deploy, maintain and improve software.",
		CustomAttributes: map[string]talent.CustomAttribute{
			"someFieldString": {
				Filterable:   true,
				StringValues: []string{"someStrVal"},
			},
			"someFieldLong": {
				Filterable: true,
				LongValues: []int64{900},
			},
		},
	}
	return job
}

Node.js

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


/**
 * Generate a job with a custom attribute.
 */
const generateJobWithACustomAttribute = (companyName) => {
  const requisitionId = `jobWithACustomAttribute: ${new Date().getTime()}`;
  const jobTitle = 'Software Engineer';
  const applicationUrls = ['http://careers.google.com'];
  const description =
    'Design, develop, test, deploy, maintain and improve software.';

  const customAttributes = {
    someFieldName1: {stringValues: ['value1'], filterable: true},
    someFieldName2: {longValues: [256], filterable: true},
  };

  const job = {
    companyName: companyName,
    requisitionId: requisitionId,
    title: jobTitle,
    applicationInfo: {uris: applicationUrls},
    description: description,
    customAttributes: customAttributes,
  };

  console.log(`Job generated: ${JSON.stringify(job)}`);
  return job;
};

Ruby

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

# company_name   = "The resource name of the company listing the job. The format is "projects/{project_id}/companies/{company_id}""
# requisition_id = "The posting ID, assigned by the client to identify a job"

require "google/apis/jobs_v3"

jobs = Google::Apis::JobsV3
talent_solution_client = jobs::CloudTalentSolutionService.new
# @see
# https://developers.google.com/identity/protocols/application-default-credentials#callingruby
talent_solution_client.authorization = Google::Auth.get_application_default(
  "https://www.googleapis.com/auth/jobs"
)
# Constructs custom attributes map
custom_attributes = {}
# First custom attribute
custom_attributes["someFieldName1"] = jobs::CustomAttribute.new string_values: ["value1"],
                                                                filterable:    true
# Second custom attribute
custom_attributes["someFieldName2"] = jobs::CustomAttribute.new long_values: [256],
                                                                filterable:  true
# Creates job with custom attributes
job_generated =
  jobs::Job.new requisition_id:    requisition_id,
                title:             " Lab Technician",
                company_name:      company_name,
                application_info:  (jobs::ApplicationInfo.new uris: ["http://careers.google.com"]),
                description:       "Design, develop, test, deploy, maintain and improve software.",
                custom_attributes: custom_attributes

puts "Featured Job generated: #{job_generated.to_json}"
job_generated

创建针对 customAttribute 字段的过滤器:

Java

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


/**
 * CustomAttributeFilter on String value CustomAttribute
 */
public static void filtersOnStringValueCustomAttribute()
    throws IOException, InterruptedException {
  // Make sure to set the requestMetadata the same as the associated search request
  RequestMetadata requestMetadata =
      new RequestMetadata()
          // Make sure to hash your userID
          .setUserId("HashedUserId")
          // Make sure to hash the sessionID
          .setSessionId("HashedSessionID")
          // Domain of the website where the search is conducted
          .setDomain(
              "www.google.com");

  String customAttributeFilter = "NOT EMPTY(someFieldName1)";
  JobQuery jobQuery = new JobQuery()
      .setCustomAttributeFilter(customAttributeFilter);

  SearchJobsRequest searchJobsRequest =
      new SearchJobsRequest()
          .setJobQuery(jobQuery)
          .setRequestMetadata(requestMetadata)
          .setJobView("JOB_VIEW_FULL");
  SearchJobsResponse response =
      talentSolutionClient
          .projects()
          .jobs()
          .search(DEFAULT_PROJECT_ID, searchJobsRequest)
          .execute();
  Thread.sleep(1000);
  System.out.println(response);
}

Python

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

def custom_attribute_filter_string_value(client_service):
    request_metadata = {
        'user_id': 'HashedUserId',
        'session_id': 'HashedSessionId',
        'domain': 'www.google.com'
    }

    custom_attribute_filter = 'NOT EMPTY(someFieldName1)'
    job_query = {'custom_attribute_filter': custom_attribute_filter}
    request = {
        'request_metadata': request_metadata,
        'job_query': job_query,
        'job_view': 'JOB_VIEW_FULL'
    }

    response = client_service.projects().jobs().search(
        parent=parent, body=request).execute()
    print(response)

C#

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


public static void FiltersOnStringValueCustomAttribute()
{
    RequestMetadata requestMetadata = new RequestMetadata()
    {
        UserId = "HashedUserId",
        SessionId = "HashedSessionId",
        Domain = "www.google.com"
    };

    string customAttributeFilter = "NOT EMPTY(custom_attribute)";
    JobQuery jobQuery = new JobQuery()
    {
        CustomAttributeFilter = customAttributeFilter
    };

    SearchJobsRequest searchJobsRequest = new SearchJobsRequest()
    {
        JobQuery = jobQuery,
        RequestMetadata = requestMetadata,
        JobView = "JOB_VIEW_FULL"
    };

    SearchJobsResponse response = jobServiceClient.Projects.Jobs.Search(searchJobsRequest, parent).Execute();

    Console.WriteLine("Searched on custom attribute: " + ToJsonString(response));
}

Go

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


// filterOnStringValueCustomAttribute searches for jobs on a string value custom
// atrribute.
func filterOnStringValueCustomAttribute(w io.Writer, projectID string) (*talent.SearchJobsResponse, error) {
	ctx := context.Background()

	client, err := google.DefaultClient(ctx, talent.CloudPlatformScope)
	if err != nil {
		return nil, fmt.Errorf("google.DefaultClient: %v", err)
	}
	// Create the jobs service client.
	service, err := talent.New(client)
	if err != nil {
		return nil, fmt.Errorf("talent.New: %v", err)
	}

	parent := "projects/" + projectID
	req := &talent.SearchJobsRequest{
		JobQuery: &talent.JobQuery{
			CustomAttributeFilter: "NOT EMPTY(someFieldString)",
		},
		// Make sure to set the RequestMetadata the same as the associated
		// search request.
		RequestMetadata: &talent.RequestMetadata{
			// Make sure to hash your userID.
			UserId: "HashedUsrId",
			// Make sure to hash the sessionID.
			SessionId: "HashedSessionId",
			// Domain of the website where the search is conducted.
			Domain: "www.googlesample.com",
		},
		JobView: "JOB_VIEW_FULL",
	}
	resp, err := service.Projects.Jobs.Search(parent, req).Do()
	if err != nil {
		return nil, fmt.Errorf("failed to search for jobs with string value custom attribute: %v", err)
	}

	fmt.Fprintln(w, "Jobs:")
	for _, j := range resp.MatchingJobs {
		fmt.Fprintf(w, "\t%q\n", j.Job.Name)
	}

	return resp, nil
}

Node.js

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


/**
 * CustomAttributeFilter on String value CustomAttribute
 */
const filtersOnStringValueCustomAttribute = async (jobServiceClient) => {
  try {
    const customAttributeFilter = 'NOT EMPTY(someFieldName1)';
    const jobQuery = {customAttributeFilter: customAttributeFilter};
    const request = {
      parent: `projects/${PROJECT_ID}`,
      resource: {
        jobQuery: jobQuery,
        requestMetadata: REQUEST_META_DATA,
        jobView: 'JOB_VIEW_FULL',
      },
    };

    const result = await jobServiceClient.projects.jobs.search(request);
    console.log(JSON.stringify(result.data));
  } catch (e) {
    console.log(e);
    throw e;
  }
};

Ruby

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

# project_id      = "Id of the project"

require "google/apis/jobs_v3"

jobs = Google::Apis::JobsV3
talent_solution_client = jobs::CloudTalentSolutionService.new
# @see https://developers.google.com/identity/protocols/application-default-credentials#callingruby
talent_solution_client.authorization = Google::Auth.get_application_default(
  "https://www.googleapis.com/auth/jobs"
)

# Make sure to set the request_metadata the same as the associated search request
request_metadata = jobs::RequestMetadata.new user_id:    "HashedUserId",
                                             session_id: "HashedSessionId",
                                             domain:     "www.google.com"

# Perform a search for analyst  related jobs
job_query = jobs::JobQuery.new custom_attribute_filter: "NOT EMPTY(someFieldName1)"
search_jobs_request = jobs::SearchJobsRequest.new request_metadata: request_metadata,
                                                  job_query:        job_query,
                                                  job_view:         "JOB_VIEW_FULL"
search_jobs_response = talent_solution_client.search_jobs project_id, search_jobs_request

puts search_jobs_response.to_json
search_jobs_response

使用 customAttribute 创建另一个过滤器:

Java

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


/**
 * CustomAttributeFilter on Long value CustomAttribute
 */
public static void filtersOnLongValueCustomAttribute() throws IOException, InterruptedException {
  // Make sure to set the requestMetadata the same as the associated search request
  RequestMetadata requestMetadata =
      new RequestMetadata()
          // Make sure to hash your userID
          .setUserId("HashedUserId")
          // Make sure to hash the sessionID
          .setSessionId("HashedSessionID")
          // Domain of the website where the search is conducted
          .setDomain("www.google.com");

  String customAttributeFilter = "(255 <= someFieldName2) AND (someFieldName2 <= 257)";
  JobQuery jobQuery = new JobQuery()
      .setCustomAttributeFilter(customAttributeFilter);

  SearchJobsRequest searchJobsRequest =
      new SearchJobsRequest()
          .setJobQuery(jobQuery)
          .setJobView("JOB_VIEW_FULL")
          .setRequestMetadata(requestMetadata);

  SearchJobsResponse response =
      talentSolutionClient
          .projects()
          .jobs()
          .search(DEFAULT_PROJECT_ID, searchJobsRequest)
          .execute();
  Thread.sleep(1000);
  System.out.println(response);
}

Python

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

def custom_attribute_filter_long_value(client_service):
    request_metadata = {
        'user_id': 'HashedUserId',
        'session_id': 'HashedSessionId',
        'domain': 'www.google.com'
    }

    custom_attribute_filter = ('(255 <= someFieldName2) AND'
                               ' (someFieldName2 <= 257)')
    job_query = {'custom_attribute_filter': custom_attribute_filter}
    request = {
        'request_metadata': request_metadata,
        'job_query': job_query,
        'job_view': 'JOB_VIEW_FULL'
    }

    response = client_service.projects().jobs().search(
        parent=parent, body=request).execute()
    print(response)

C#

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


public static void FiltersOnLongValueCustomAttribute()
{
    RequestMetadata requestMetadata = new RequestMetadata()
    {
        UserId = "HashedUserId",
        SessionId = "HashedSessionId",
        Domain = "www.google.com"
    };

    string customAttributeFilter = "(255 <= someFieldName2) AND (someFieldName2 <= 267)";
    JobQuery jobQuery = new JobQuery()
    {
        CustomAttributeFilter = customAttributeFilter
    };

    SearchJobsRequest searchJobsRequest = new SearchJobsRequest()
    {
        JobQuery = jobQuery,
        RequestMetadata = requestMetadata,
        JobView = "JOB_VIEW_FULL"
    };

    SearchJobsResponse response = jobServiceClient.Projects.Jobs.Search(searchJobsRequest, parent).Execute();

    Console.WriteLine("Searched on custom long attribute: " + ToJsonString(response));
}

Go

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


// filterOnLongValueCustomAttribute searches for jobs on a long value custom
// atrribute.
func filterOnLongValueCustomAttribute(w io.Writer, projectID string) (*talent.SearchJobsResponse, error) {
	ctx := context.Background()

	client, err := google.DefaultClient(ctx, talent.CloudPlatformScope)
	if err != nil {
		return nil, fmt.Errorf("google.DefaultClient: %v", err)
	}
	// Create the jobs service client.
	service, err := talent.New(client)
	if err != nil {
		return nil, fmt.Errorf("talent.New: %v", err)
	}

	parent := "projects/" + projectID
	req := &talent.SearchJobsRequest{
		JobQuery: &talent.JobQuery{
			CustomAttributeFilter: "someFieldLong < 1000",
		},
		// Make sure to set the RequestMetadata the same as the associated
		// search request.
		RequestMetadata: &talent.RequestMetadata{
			// Make sure to hash your userID.
			UserId: "HashedUsrId",
			// Make sure to hash the sessionID.
			SessionId: "HashedSessionId",
			// Domain of the website where the search is conducted.
			Domain: "www.googlesample.com",
		},
		JobView: "JOB_VIEW_FULL",
	}
	resp, err := service.Projects.Jobs.Search(parent, req).Do()
	if err != nil {
		return nil, fmt.Errorf("failed to search for jobs with long value custom attribute: %v", err)
	}

	fmt.Fprintln(w, "Jobs:")
	for _, j := range resp.MatchingJobs {
		fmt.Fprintf(w, "\t%q\n", j.Job.Name)
	}

	return resp, nil
}

Node.js

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


/**
 * CustomAttributeFilter on Long value CustomAttribute
 */
const filtersOnLongValueCustomAttribute = async (jobServiceClient) => {
  try {
    const customAttributeFilter =
      '(255 <= someFieldName2) AND' + ' (someFieldName2 <= 257)';
    const jobQuery = {customAttributeFilter: customAttributeFilter};
    const request = {
      parent: `projects/${PROJECT_ID}`,
      resource: {
        jobQuery: jobQuery,
        requestMetadata: REQUEST_META_DATA,
        jobView: 'JOB_VIEW_FULL',
      },
    };

    const result = await jobServiceClient.projects.jobs.search(request);
    console.log(JSON.stringify(result.data));
  } catch (e) {
    console.log(e);
    throw e;
  }
};

Ruby

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

# project_id       = "Id of the project"

require "google/apis/jobs_v3"

jobs = Google::Apis::JobsV3
talent_solution_client = jobs::CloudTalentSolutionService.new
# @see https://developers.google.com/identity/protocols/application-default-credentials#callingruby
talent_solution_client.authorization = Google::Auth.get_application_default(
  "https://www.googleapis.com/auth/jobs"
)
# Make sure to set the request_metadata the same as the associated search request
request_metadata = jobs::RequestMetadata.new user_id:    "HashedUserId",
                                             session_id: "HashedSessionId",
                                             domain:     "www.google.com"
# Perform a search for analyst  related jobs
custom_attribute_filter = "(255 <= someFieldName2) AND (someFieldName2 <= 257)"
job_query = jobs::JobQuery.new custom_attribute_filter: custom_attribute_filter
search_jobs_request = jobs::SearchJobsRequest.new request_metadata: request_metadata,
                                                  job_query:        job_query,
                                                  job_view:         "JOB_VIEW_FULL"
search_jobs_response = talent_solution_client.search_jobs project_id, search_jobs_request

puts search_jobs_response.to_json
search_jobs_response

利用自定义属性来促进跨字段过滤:

以下示例展示了如何定义搜索请求,以搜索目标奖金比率介于 10% 至 20% 之间的招聘信息,或者要求“团队管理”技能的招聘信息,或者“visa_required”customAttribute 属性值非空的招聘信息。

Java

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


/**
 * CustomAttributeFilter on multiple CustomAttributes
 */
public static void filtersOnMultiCustomAttributes() throws IOException, InterruptedException {
  // Make sure to set the requestMetadata the same as the associated search request
  RequestMetadata requestMetadata =
      new RequestMetadata()
          // Make sure to hash your userID
          .setUserId("HashedUserId")
          // Make sure to hash the sessionID
          .setSessionId("HashedSessionID")
          // Domain of the website where the search is conducted
          .setDomain(
              "www.google.com");

  String customAttributeFilter = "(someFieldName1 = \"value1\") "
      + "AND ((255 <= someFieldName2) OR (someFieldName2 <= 213))";
  JobQuery jobQuery = new JobQuery()
      .setCustomAttributeFilter(customAttributeFilter);

  SearchJobsRequest searchJobsRequest =
      new SearchJobsRequest()
          .setJobQuery(jobQuery)
          .setRequestMetadata(requestMetadata)
          .setJobView("JOB_VIEW_FULL");
  SearchJobsResponse response =
      talentSolutionClient
          .projects()
          .jobs()
          .search(DEFAULT_PROJECT_ID, searchJobsRequest)
          .execute();
  Thread.sleep(1000);
  System.out.println(response);
}

Python

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

def custom_attribute_filter_multi_attributes(client_service):
    request_metadata = {
        'user_id': 'HashedUserId',
        'session_id': 'HashedSessionId',
        'domain': 'www.google.com'
    }

    custom_attribute_filter = (
        '(someFieldName1 = "value1") AND ((255 <= someFieldName2) OR '
        '(someFieldName2 <= 213))')
    job_query = {'custom_attribute_filter': custom_attribute_filter}
    request = {
        'request_metadata': request_metadata,
        'job_query': job_query,
        'job_view': 'JOB_VIEW_FULL'
    }

    response = client_service.projects().jobs().search(
        parent=parent, body=request).execute()
    print(response)

C#

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


public static void FiltersOnMultiCustomAttributes()
{
    RequestMetadata requestMetadata = new RequestMetadata()
    {
        UserId = "HashedUserId",
        SessionId = "HashedSessionId",
        Domain = "www.google.com"
    };

    string customAttributeFilter = "(someFiledName1 = \"value1\") " +
        "AND ((255 <= someFieldName2) OR (someFieldName2 <= 213))";
    JobQuery jobQuery = new JobQuery()
    {
        CustomAttributeFilter = customAttributeFilter
    };

    SearchJobsRequest searchJobsRequest = new SearchJobsRequest()
    {
        JobQuery = jobQuery,
        RequestMetadata = requestMetadata,
        JobView = "JOB_VIEW_FULL"
    };

    SearchJobsResponse response = jobServiceClient.Projects.Jobs.Search(searchJobsRequest, parent).Execute();

    Console.WriteLine("Searched on cross-field-filtering: " + ToJsonString(response));
}

Go

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


// filterOnLongValueCustomAttribute searches for jobs on multiple custom
// atrributes.
func filterOnMultiCustomAttributes(w io.Writer, projectID string) (*talent.SearchJobsResponse, error) {
	ctx := context.Background()

	client, err := google.DefaultClient(ctx, talent.CloudPlatformScope)
	if err != nil {
		return nil, fmt.Errorf("google.DefaultClient: %v", err)
	}
	// Create the jobs service client.
	service, err := talent.New(client)
	if err != nil {
		return nil, fmt.Errorf("talent.New: %v", err)
	}

	parent := "projects/" + projectID
	req := &talent.SearchJobsRequest{
		JobQuery: &talent.JobQuery{
			CustomAttributeFilter: "(someFieldString = \"someStrVal\") AND (someFieldLong < 1000)",
		},
		// Make sure to set the RequestMetadata the same as the associated
		// search request.
		RequestMetadata: &talent.RequestMetadata{
			// Make sure to hash your userID.
			UserId: "HashedUsrId",
			// Make sure to hash the sessionID.
			SessionId: "HashedSessionId",
			// Domain of the website where the search is conducted.
			Domain: "www.googlesample.com",
		},
		JobView: "JOB_VIEW_FULL",
	}
	resp, err := service.Projects.Jobs.Search(parent, req).Do()
	if err != nil {
		return nil, fmt.Errorf("failed to search for jobs with multiple custom attributes: %v", err)
	}

	fmt.Fprintln(w, "Jobs:")
	for _, j := range resp.MatchingJobs {
		fmt.Fprintf(w, "\t%q\n", j.Job.Name)
	}

	return resp, nil
}

Node.js

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


/**
 * CustomAttributeFilter on multiple CustomAttributes
 */
const filtersOnMultiCustomAttributes = async (jobServiceClient) => {
  try {
    const customAttributeFilter =
      '(someFieldName1 = "value1") AND ((255 <= someFieldName2) OR ' +
      '(someFieldName2 <= 213))';
    const jobQuery = {customAttributeFilter: customAttributeFilter};
    const request = {
      parent: `projects/${PROJECT_ID}`,
      resource: {
        jobQuery: jobQuery,
        requestMetadata: REQUEST_META_DATA,
        jobView: 'JOB_VIEW_FULL',
      },
    };

    const result = await jobServiceClient.projects.jobs.search(request);
    console.log(JSON.stringify(result.data));
  } catch (e) {
    console.log(e);
    throw e;
  }
};

Ruby

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

# project_id       = "Id of the project"

require "google/apis/jobs_v3"

jobs = Google::Apis::JobsV3
talent_solution_client = jobs::CloudTalentSolutionService.new
# @see
# https://developers.google.com/identity/protocols/application-default-credentials#callingruby
talent_solution_client.authorization = Google::Auth.get_application_default(
  "https://www.googleapis.com/auth/jobs"
)

# Make sure to set the request_metadata the same as the associated search request
request_metadata = jobs::RequestMetadata.new user_id:    "HashedUserId",
                                             session_id: "HashedSessionId",
                                             domain:     "www.google.com"
custom_attribute_filter = "NOT EMPTY(someFieldName1) "\
  "AND ((255 <= someFieldName2) OR (someFieldName2 <= 213))"
job_query = jobs::JobQuery.new custom_attribute_filter: custom_attribute_filter
search_jobs_request = jobs::SearchJobsRequest.new request_metadata: request_metadata,
                                                  job_query:        job_query,
                                                  job_view:         "JOB_VIEW_FULL"
search_jobs_response = talent_solution_client.search_jobs project_id, search_jobs_request

puts search_jobs_response.to_json
search_jobs_response

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

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