Preenchimento automático

A Cloud Talent Solution oferece sugestões de preenchimento automático para cargos e nomes de empresas. Somente ofertas de empregos ativas e empresas com pelo menos uma vaga aberta são consideradas qualificadas para resultados de sugestões. Depois que uma nova vaga ou empresa for adicionada, levará até 48 horas para que as informações sejam adicionadas ao conjunto de resultados de preenchimento automático.

Para usar o preenchimento automático, chame o método complete quando a barra de pesquisa for atualizada.

Go

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	talentpb "google.golang.org/genproto/googleapis/cloud/talent/v4beta1"
)

// jobTitleAutoComplete suggests the job titles of the given
// company identifier on query.
func jobTitleAutocomplete(w io.Writer, projectID, query string) (*talentpb.CompleteQueryResponse, error) {
	ctx := context.Background()

	// Initialize a completionService client.
	c, err := talent.NewCompletionClient(ctx)
	if err != nil {
		return nil, fmt.Errorf("talent.NewCompletionClient: %v", err)
	}

	// Construct a completeQuery request.
	req := &talentpb.CompleteQueryRequest{
		Parent:        fmt.Sprintf("projects/%s", projectID),
		Query:         query,
		LanguageCodes: []string{"en-US"},
		PageSize:      5, // Number of completion results returned.
		Scope:         talentpb.CompleteQueryRequest_PUBLIC,
		Type:          talentpb.CompleteQueryRequest_JOB_TITLE,
	}

	resp, err := c.CompleteQuery(ctx, req)
	if err != nil {
		return nil, fmt.Errorf("CompleteQuery(%s): %v", query, err)
	}

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

	return resp, nil
}

Java

Para mais informações sobre a instalação e criação de um cliente no Cloud Talent Solution, consulte Bibliotecas de clientes do Cloud Talent Solution.


import com.google.cloud.talent.v4beta1.CompleteQueryRequest;
import com.google.cloud.talent.v4beta1.CompleteQueryResponse;
import com.google.cloud.talent.v4beta1.CompletionClient;
import com.google.cloud.talent.v4beta1.TenantName;
import java.io.IOException;

public class JobSearchAutoCompleteJobTitle {

  public static void completeQuery() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    String query = "your-query-for-job-title";
    completeQuery(projectId, tenantId, query);
  }

  // Complete job title given partial text (autocomplete).
  public static void completeQuery(String projectId, String tenantId, String query)
      throws IOException {
    try (CompletionClient completionClient = CompletionClient.create()) {
      TenantName parent = TenantName.of(projectId, tenantId);
      CompleteQueryRequest request =
          CompleteQueryRequest.newBuilder()
              .setParent(parent.toString())
              .setQuery(query)
              .setPageSize(5) // limit for number of results
              .addLanguageCodes("en-US") // language code
              .build();
      CompleteQueryResponse response = completionClient.completeQuery(request);
      for (CompleteQueryResponse.CompletionResult result : response.getCompletionResultsList()) {
        System.out.printf("Suggested title: %s\n", result.getSuggestion());
        // Suggestion type is JOB_TITLE or COMPANY_TITLE
        System.out.printf("Suggestion type: %s\n", result.getType());
      }
    }
  }
}

PHP

Para mais informações sobre a instalação e criação de um cliente no Cloud Talent Solution, consulte Bibliotecas de clientes do Cloud Talent Solution.

require __DIR__ . '/vendor/autoload.php';

use Google\Cloud\Talent\V4beta1\CompletionClient;

/**
 * Complete job title given partial text (autocomplete).
 *
 * @param string $projectId Your Google Cloud Project ID
 * @param string $tenantId  Identifier of the Tenantd
 */
function sampleCompleteQuery($projectId, $tenantId, $query, $numResults, $languageCode)
{

    $completionClient = new CompletionClient();

    // $projectId = 'Your Google Cloud Project ID';
    // $tenantId = 'Your Tenant ID (using tenancy is optional)';
    // $query = '[partially typed job title]';
    // $numResults = 5;
    // $languageCode = 'en-US';
    $formattedParent = $completionClient->tenantName($projectId, $tenantId);
    $languageCodes = [$languageCode];

    try {
        $response = $completionClient->completeQuery($formattedParent, $query, $numResults, ['languageCodes' => $languageCodes]);
        foreach ($response->getCompletionResults() as $result) {
            printf('Suggested title: %s'.PHP_EOL, $result->getSuggestion());
            // Suggestion type is JOB_TITLE or COMPANY_TITLE
            printf('Suggestion type: %s'.PHP_EOL, CompleteQueryRequest_CompletionType::name($result->getType()));
        }
    } finally {
        $completionClient->close();
    }

}

Ruby

Para mais informações sobre a instalação e criação de um cliente no Cloud Talent Solution, consulte Bibliotecas de clientes do Cloud Talent Solution.


# Complete job title given partial text (autocomplete)
#
# @param project_id {String} Your Google Cloud Project ID
# @param tenant_id {String} Identifier of the Tenantd
def sample_complete_query project_id, tenant_id, query, num_results, language_code
  # Instantiate a client
  completion_client = Google::Cloud::Talent::Completion.new version: :v4beta1

  # project_id = "Your Google Cloud Project ID"
  # tenant_id = "Your Tenant ID (using tenancy is optional)"
  # query = "[partially typed job title]"
  # num_results = 5
  # language_code = "en-US"
  formatted_parent = completion_client.class.tenant_path(project_id, tenant_id)
  language_codes = [language_code]

  response = completion_client.complete_query(formatted_parent, query, num_results, language_codes: language_codes)
  response.completion_results.each do |result|
    puts "Suggested title: #{result.suggestion}"
    # Suggestion type is JOB_TITLE or COMPANY_TITLE
    puts "Suggestion type: #{result.type}"
  end
end

C#

Para mais informações sobre a instalação e criação de um cliente no Cloud Talent Solution, consulte Bibliotecas de clientes do Cloud Talent Solution.

public static object CompleteQuery(string projectId, string tenantId, string query)
{
    CompletionClient completionClient = CompletionClient.Create();
    TenantName tenant = TenantName.FromProjectTenant(projectId, tenantId);
    CompleteQueryRequest request = new CompleteQueryRequest
    {
        ParentAsTenantName = tenant,
        Query = query, // partial text for job title
        PageSize = 5, // limit for number of results
        LanguageCodes = { "en-US" } // language code
    };
    var response = completionClient.CompleteQuery(request);
    foreach (var result in response.CompletionResults)
    {
        Console.WriteLine($"Suggested title: {result.Suggestion}");
        // Suggestion type is JOB_TITLE or COMPANY_TITLE
        Console.WriteLine($"Suggestion type: {result.Type}");
    }

    return 0;
}