Guida rapida: Ricerca (v3)

Cloud Talent Solution ti consente di cercare le offerte di lavoro che hai pubblicato nel nostro sistema in Google Cloud Talent Solution e che sono attualmente attive. Questo tutorial fornisce una semplice chiamata di ricerca per il job creato in Creare aziende e job.

Una volta che puoi effettuare richieste di ricerca, assicurati di implementare il framework di analisi dei lavori (vedi Migliorare il modello preaddestrato). Questo è fondamentale per il valore di Cloud Talent Solution e influisce direttamente sul miglioramento risultati di ricerca.

Cerca l'offerta di lavoro

Cerca il job creato nel tutorial Creare aziende e job. Cloud Talent Solution utilizza inoltre RequestMetadata per garantire attivamente che i candidati ricevano un'esperienza utente coerente durante la ricerca di offerte di lavoro. È obbligatorio assicurarsi che questo campo sia impostato correttamente. Consulta la documentazione di RequestMetadata.

Java

Per saperne di più sull'installazione e sulla creazione di un client Cloud Talent Solution, consulta Librerie client di Cloud Talent Solution.


/** Simple search jobs with keyword. */
public static void basicSearcJobs(String companyName, String query)
    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");

  // Perform a search for analyst  related jobs
  JobQuery jobQuery = new JobQuery().setQuery(query);
  if (companyName != null) {
    jobQuery.setCompanyNames(Arrays.asList(companyName));
  }

  SearchJobsRequest searchJobsRequest =
      new SearchJobsRequest()
          .setRequestMetadata(requestMetadata)
          .setJobQuery(jobQuery) // Set the actual search term as defined in the jobQurey
          .setSearchMode("JOB_SEARCH"); // Set the search mode to a regular search

  SearchJobsResponse searchJobsResponse =
      talentSolutionClient
          .projects()
          .jobs()
          .search(DEFAULT_PROJECT_ID, searchJobsRequest)
          .execute();
  Thread.sleep(1000);
  System.out.printf("Simple search jobs results: %s\n", searchJobsResponse);
}

Python

Per saperne di più sull'installazione e sulla creazione di un client Cloud Talent Solution, consulta Librerie client di Cloud Talent Solution.

def basic_keyword_search(client_service, company_name, keyword):
    request_metadata = {
        "user_id": "HashedUserId",
        "session_id": "HashedSessionId",
        "domain": "www.google.com",
    }
    job_query = {"query": keyword}
    if company_name is not None:
        job_query.update({"company_names": [company_name]})
    request = {
        "search_mode": "JOB_SEARCH",
        "request_metadata": request_metadata,
        "job_query": job_query,
    }

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

Go

Per saperne di più sull'installazione e sulla creazione di un client Cloud Talent Solution, consulta Librerie client di Cloud Talent Solution.


// basicJobSearch searches for jobs with query.
func basicJobSearch(w io.Writer, projectID, companyName, query string) (*talent.SearchJobsResponse, error) {
	ctx := context.Background()

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

	jobQuery := &talent.JobQuery{
		Query: query,
	}
	if companyName != "" {
		jobQuery.CompanyNames = []string{companyName}
	}

	parent := "projects/" + projectID
	req := &talent.SearchJobsRequest{
		// 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",
		},
		// Set the actual search term as defined in the jobQuery
		JobQuery: jobQuery,
		// Set the search mode to a regular search
		SearchMode: "JOB_SEARCH",
	}
	resp, err := service.Projects.Jobs.Search(parent, req).Do()
	if err != nil {
		return nil, fmt.Errorf("failed to search for jobs with query %q: %w", query, err)
	}

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

	return resp, nil
}

Ottenere un'istogramma del numero di job per un determinato campo

L'API di ricerca restituisce anche un istogramma di tutti i job pertinenti indicizzati in Cloud Talent Solution che corrispondono ai filtri della query di ricerca. Ora che hai ottenuto i risultati di ricerca, puoi ottenere un conteggio dei job in base a diverse sfaccettature. Utilizza l'API istogramma per ottenere il conteggio dei job in base a determinate sfaccettature.

Java

Per saperne di più sull'installazione e sulla creazione di un client Cloud Talent Solution, consulta Librerie client di Cloud Talent Solution.


/** Histogram search */
public static void histogramSearch(String companyName) 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");

  HistogramFacets histogramFacets =
      new HistogramFacets()
          .setSimpleHistogramFacets(Arrays.asList("COMPANY_ID"))
          .setCustomAttributeHistogramFacets(
              Arrays.asList(
                  new CustomAttributeHistogramRequest()
                      .setKey("someFieldName1")
                      .setStringValueHistogram(true)));

  // conducted.
  SearchJobsRequest searchJobsRequest =
      new SearchJobsRequest()
          .setRequestMetadata(requestMetadata)
          .setSearchMode("JOB_SEARCH")
          .setHistogramFacets(histogramFacets);
  if (companyName != null) {
    searchJobsRequest.setJobQuery(new JobQuery().setCompanyNames(Arrays.asList(companyName)));
  }

  SearchJobsResponse searchJobsResponse =
      talentSolutionClient
          .projects()
          .jobs()
          .search(DEFAULT_PROJECT_ID, searchJobsRequest)
          .execute();
  Thread.sleep(1000);

  System.out.printf("Histogram search results: %s\n", searchJobsResponse);
}

Python

Per saperne di più sull'installazione e sulla creazione di un client Cloud Talent Solution, consulta Librerie client di Cloud Talent Solution.

def histogram_search(client_service, company_name):
    request_metadata = {
        "user_id": "HashedUserId",
        "session_id": "HashedSessionId",
        "domain": "www.google.com",
    }
    custom_attribute_histogram_facet = {
        "key": "someFieldName1",
        "string_value_histogram": True,
    }
    histogram_facets = {
        "simple_histogram_facets": ["COMPANY_ID"],
        "custom_attribute_histogram_facets": [custom_attribute_histogram_facet],
    }
    request = {
        "search_mode": "JOB_SEARCH",
        "request_metadata": request_metadata,
        "histogram_facets": histogram_facets,
    }
    if company_name is not None:
        request.update({"job_query": {"company_names": [company_name]}})
    response = (
        client_service.projects().jobs().search(parent=parent, body=request).execute()
    )
    print(response)

Go

Per saperne di più sull'installazione e sulla creazione di un client Cloud Talent Solution, consulta Librerie client di Cloud Talent Solution.


// histogramSearch searches for jobs with histogram facets.
func histogramSearch(w io.Writer, projectID, companyName string) (*talent.SearchJobsResponse, error) {
	ctx := context.Background()

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

	parent := "projects/" + projectID
	req := &talent.SearchJobsRequest{
		// 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",
		},
		HistogramFacets: &talent.HistogramFacets{
			SimpleHistogramFacets: []string{"COMPANY_ID"},
			CustomAttributeHistogramFacets: []*talent.CustomAttributeHistogramRequest{
				{
					Key:                  "someFieldString",
					StringValueHistogram: true,
				},
			},
		},
		// Set the search mode to a regular search.
		SearchMode:               "JOB_SEARCH",
		RequirePreciseResultSize: true,
	}
	if companyName != "" {
		req.JobQuery = &talent.JobQuery{
			CompanyNames: []string{companyName},
		}
	}

	resp, err := service.Projects.Jobs.Search(parent, req).Do()
	if err != nil {
		return nil, fmt.Errorf("failed to search for jobs with Historgram Facets: %w", err)
	}

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

	return resp, nil
}

In questo caso, otteniamo il conteggio di tutti i job nel sistema accettati dai filtri specificati nelle varie sfaccettature: CATEGORY e CITY.

L'API completa suggerisce titoli di lavoro o di aziende che potrebbero interessare a chi cerca lavoro in base a ciò che ha già digitato. Utilizzalo per completare automaticamente i potenziali risultati nella barra di ricerca dell'interfaccia utente.

Java

Per saperne di più sull'installazione e sulla creazione di un client Cloud Talent Solution, consulta Librerie client di Cloud Talent Solution.


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

Per saperne di più sull'installazione e sulla creazione di un client Cloud Talent Solution, consulta Librerie client di Cloud Talent Solution.

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)

Go

Per saperne di più sull'installazione e sulla creazione di un client Cloud Talent Solution, consulta Librerie client di Cloud Talent Solution.


// 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: %w", err)
	}
	// Create the jobs service client.
	service, err := talent.New(client)
	if err != nil {
		return nil, fmt.Errorf("talent.New: %w", 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: %w", query, companyName, err)
	}

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

	return resp, nil
}

Configura il framework di analisi dei dati per ottimizzare Cloud Talent Solution con gli eventi client

Ora puoi ottimizzare i risultati di ricerca per il tuo sito (consulta Migliorare i risultati di ricerca utilizzando gli eventi client). Si tratta di un passaggio fondamentale per migliorare i risultati per chi cerca un lavoro ottimizzando i risultati di ricerca.