Custom attributes (v3)

Cloud Talent Solution provides several different job attributes out-of-the-box to support the needs of various customers. To gain the best performance from Cloud Talent Solution, it's highly recommended you use the out-of-the-box fields as much as possible.

In addition, Cloud Talent Solution also provides custom attributes to store generic information. Custom attributes are used to provide even more flexibility to allow customers to support their business logic. Custom attributes store either a string or numerical information, and can be filtered against in search queries by setting appropriate filters.

Custom attributes features

  • Define your own custom field name: Define a name for a particular attribute of a job. Set this attribute to be either filterable or non-filterable depending on the need. Typically, if the UI needs a filterable facet that is not provided out-of-the-box by Cloud Talent Solution a customAttribute can be used to provide the right filtering.
  • Case (in)sensitive search: Each search request can specify whether the search against all custom attributes is case sensitive or case insensitive.
  • Range based filtering: customAttribute search filters can filter jobs between a range of specified numeric values. For example, if a given customAttribute field is used to store the minimum GPA requirements of a job, the customAttribute search filter can be used to return jobs within a certain minimum GPA range, greater than a minimum GPA value, lesser than a minimum GPA value, etc.
  • Cross-field filtering: customAttribute also provides customers of Cloud Talent Solution with the ability to define expressions that filter a combination of custom attributes. For example, a customer has business logic that states they only want jobs that sponsor visas, or telecommute jobs. The customer stores both these fields in a different customAttribute. The customer can then specify a search filter with an expression that defines the logic needed. Only 3 levels of nested expressions are supported.

  • Keyword specific search: Specify a certain customAttribute in the keywordSearchableCustomAttributes of the associated company to ensure search requests that contain a value in the specified customAttribute return the jobs containing this value in that customAttribute.

  • SQL based searches: customAttribute allows you to define boolean-style expressions in the search request. Cloud Talent Solution automatically parses these expressions, applies the filters to the search request, and returns results accordingly. Only 3 levels of nesting of the boolean expressions and at most 2000 characters are allowed.

  • Define custom histogram buckets: Custom attributes allow customers of Cloud Talent Solution to set custom buckets by which histograms can be calculated. For example, you can use a customAttribute to store minimum GPA information, and then create a histogram on this field. You can further create buckets from 3.0 - 3.5, 3.51 - 4.0, etc., to group all the minimum GPAs within these buckets.

Using custom attributes

Create a new job with the customAttribute field (can be used with either numeric or string values):

Java

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


/** 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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

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#

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


// 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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


/**
 * 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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

# 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

Create a filter on the customAttribute field:

Java

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


/** 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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

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#

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


// 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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


/**
 * 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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

# 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

Create another filter with customAttribute:

Java

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


/** 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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

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#

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


// 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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


/**
 * 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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

# 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

Leverage custom attributes to facilitate cross-field-filtering:

The following example illustrates how to define a search request that searches for jobs with a target bonus rate between 10% and 20%, or a job which required the skills of "Team Management", OR a job which has a non-empty value in the "visa_required" customAttribute.

Java

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


/** 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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

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#

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


// 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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.


/**
 * 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

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

# 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

By default, the searchJobs and seachJobsForAlert endpoints only search against out-of-the-box fields. If you also need to search against customAttribute fields, use the keywordSearchableJobCustomAttributes field to define a list of custom attributes to search.

For example, if a recruiter wishes to use a customAttribute "customRequisitions" to store the requisition ids of jobs particular to a specific employer, then by setting keywordSearchableJobCustomAttributes to include this field, a regular search conducted by a recruiter for "ABC123" returns all jobs that have the customAttribute "customRequisitions" with a value of "ABC123".