Automatische Vervollständigung (v3)

Cloud Talent Solution macht Vorschläge zur automatischen Vervollständigung von Jobtiteln und Namen von Unternehmen. Nur aktive Jobanzeigen und Unternehmen mit mindestens einem offenen Job kommen für Vorschlagsergebnisse infrage. Wenn ein neuer Job oder ein neues Unternehmen hinzugefügt wird, dauert es bis zu 48 Stunden, bis die Informationen in der Ergebnismenge der automatischen Vervollständigung enthalten sind.

Wenn die Suchleiste aktualisiert wird, rufen Sie zur Verwendung der automatischen Vervollständigung die Methode complete auf.

Java

Weitere Informationen zum Installieren und Erstellen eines Cloud Talent Solution-Clients finden Sie unter Cloud Talent Solution-Clientbibliotheken.

  /**
   * 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);
  }

  /**
   * Auto completes job titles within given companyName.
   */
  public static void defaultAutoComplete(String companyName, String query)
      throws IOException {
    Complete complete =
        talentSolutionClient
            .projects()
            .complete(DEFAULT_PROJECT_ID)
            .setQuery(query)
            .setLanguageCode("en-US")
            .setPageSize(10);
    if (companyName != null) {
      complete.setCompanyName(companyName);
    }

    CompleteQueryResponse results = complete.execute();

    System.out.println(results);
  }

  public static void main(String... args) throws Exception {
    Company companyToBeCreated = BasicCompanySample.generateCompany().setDisplayName("Google");
    String companyName = BasicCompanySample.createCompany(companyToBeCreated).getName();

    Job jobToBeCreated = BasicJobSample.generateJobWithRequiredFields(companyName)
        .setTitle("Software engineer");
    final String jobName = BasicJobSample.createJob(jobToBeCreated).getName();

    // Wait several seconds for post processing
    Thread.sleep(10000);
    defaultAutoComplete(companyName, "goo");
    defaultAutoComplete(companyName, "sof");
    jobTitleAutoComplete(companyName, "sof");

    BasicJobSample.deleteJob(jobName);
    BasicCompanySample.deleteCompany(companyName);
  }
}

Python

Weitere Informationen zum Installieren und Erstellen eines Cloud Talent Solution-Clients finden Sie unter Cloud Talent Solution-Clientbibliotheken.

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)

C#

Weitere Informationen zum Installieren und Erstellen eines Cloud Talent Solution-Clients finden Sie unter Cloud Talent Solution-Clientbibliotheken.

public static void JobTitleAutoComplete(String companyName, String query)
{
    CompleteRequest completeRequest = new CompleteRequest(jobServiceClient, parent)
    {
        Query = query,
        LanguageCode = "en-US",
        Type = CompleteRequest.TypeEnum.JOBTITLE,
        PageSize = 10
    };

    if (companyName != null)
    {
        completeRequest.CompanyName = companyName;
    }

    CompleteQueryResponse results = completeRequest.Execute();
    Console.WriteLine("Completion results: " + ToJsonString(results));
}

Go

Weitere Informationen zum Installieren und Erstellen eines Cloud Talent Solution-Clients finden Sie unter Cloud Talent Solution-Clientbibliotheken.

// jobTitleAutoComplete suggests the job titles of the given companyName based
// on query.
func jobTitleAutoComplete(w io.Writer, projectID, companyName, query string) (*talent.CompleteQueryResponse, 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
	complete := service.Projects.Complete(parent).Query(query).LanguageCode("en-US").Type("JOB_TITLE").PageSize(10)
	if companyName != "" {
		complete.CompanyName(companyName)
	}
	resp, err := complete.Do()
	if err != nil {
		return nil, fmt.Errorf("failed to auto complete with query %s in company %s: %v", query, companyName, err)
	}

	fmt.Fprintf(w, "Auto complete results:")
	for _, c := range resp.CompletionResults {
		fmt.Fprintf(w, "\t%v", c.Suggestion)
	}

	return resp, nil
}

Node.js

Weitere Informationen zum Installieren und Erstellen eines Cloud Talent Solution-Clients finden Sie unter Cloud Talent Solution-Clientbibliotheken.

/**
 * Auto completes job titles within given companyName.
 */
const jobTitleAutoComplete = async (jobServiceClient, query, companyName) => {
  try {
    const request = {
      name: `projects/${PROJECT_ID}`,
      query: query,
      languageCode: 'en-US',
      type: 'JOB_TITLE',
      pageSize: 10,
    };

    if (companyName) {
      request.companyName = companyName;
    }

    const complete = await jobServiceClient.projects.complete(request);

    console.log(JSON.stringify(complete.data));
  } catch (e) {
    console.error(e);
    throw e;
  }
};

Ruby

Weitere Informationen zum Installieren und Erstellen eines Cloud Talent Solution-Clients finden Sie unter Cloud Talent Solution-Clientbibliotheken.

# project_id     = "Project id required"
# company_name   = "The resource name of the company listing the job. The format is "projects/{project_id}/companies/{company_id}""
# query          = "Job title prefix as auto complete query"

require "google/apis/jobs_v3"

jobs = Google::Apis::JobsV3
talent_solution_client = jobs::CloudTalentSolutionService.new
talent_solution_client.authorization = Google::Auth.get_application_default(
  "https://www.googleapis.com/auth/jobs"
)

page_size = 10
type = "JOB_TITLE"
language_code = "en-US"
result = talent_solution_client.complete_project(
  project_id, company_name: company_name, page_size: page_size, query: query,
    language_code: language_code, type: type
) do |result, err|
  if err.nil?
    puts "Job title auto complete result: #{result.to_json}"
  else
    puts "Error when auto completing job title. Error message: #{err.to_json}"
  end
end
result