Autocomplete (v3)

Cloud Talent Solution provides autocomplete suggestions for job titles and company names. Only active job postings and companies with at least one open job are considered eligible for suggestion results. Once a new job or company is added, it takes up to 48 hours for the information to be added to the autocomplete result set.

To use autocomplete, call the complete method when the search bar is updated.

Java

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


/** Auto completes job titles within given companyName. */
public static void jobTitleAutoComplete(String companyName, String query) throws IOException {

  Complete complete =
      talentSolutionClient
          .projects()
          .complete(DEFAULT_PROJECT_ID)
          .setQuery(query)
          .setLanguageCode("en-US")
          .setType("JOB_TITLE")
          .setPageSize(10);
  if (companyName != null) {
    complete.setCompanyName(companyName);
  }

  CompleteQueryResponse results = complete.execute();

  System.out.println(results);
}

Python

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

def job_title_auto_complete(client_service, query, company_name):
    complete = client_service.projects().complete(
        name=name, query=query, languageCode="en-US", type="JOB_TITLE", pageSize=10
    )
    if company_name is not None:
        complete.companyName = company_name

    results = complete.execute()
    print(results)

Node.js

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


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

/**
 * Complete job title given partial text (autocomplete)
 *
 * @param projectId {string} Your Google Cloud Project ID
 * @param tenantId {string} Identifier of the TenantId
 */
function sampleCompleteQuery(
  projectId,
  tenantId,
  query,
  numResults,
  languageCode
) {
  const client = new talent.CompletionClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const query = '[partially typed job title]';
  // const numResults = 5;
  // const languageCode = 'en-US';
  const formattedParent = client.tenantPath(projectId, tenantId);
  const languageCodes = [languageCode];
  const request = {
    parent: formattedParent,
    query: query,
    pageSize: numResults,
    languageCodes: languageCodes,
  };
  client
    .completeQuery(request)
    .then(responses => {
      const response = responses[0];
      for (const result of response.completionResults) {
        console.log(`Suggested title: ${result.suggestion}`);
        // Suggestion type is JOB_TITLE or COMPANY_TITLE
        console.log(`Suggestion type: ${result.type}`);
      }
    })
    .catch(err => {
      console.error(err);
    });
}