Penelusuran perjalanan (v3)

Permintaan penelusuran lowongan dapat menyertakan filter waktu perjalanan yang membatasi lowongan yang ditampilkan untuk pekerjaan yang berada dalam waktu perjalanan tertentu dari titik awal. Hasil mencakup perkiraan waktu perjalanan dalam detik untuk lowongan yang cocok.

Untuk menampilkan pekerjaan dalam waktu perjalanan tertentu, kirim permintaan jobs.search dan sertakan objek CommuteFilter di kolom JobQuery.commuteFilter. Cloud Talent Solution menggunakan alamat lowongan untuk menghitung waktu perjalanan ke lowongan tersebut. Jika alamat mendetail tidak diberikan, Cloud Talent Solution akan mencoba menyimpulkan alamat jalan sebenarnya dari pekerjaan tersebut.

Java

Untuk mengetahui informasi lebih lanjut tentang cara menginstal dan membuat klien Cloud Talent Solution, lihat Library Klien Cloud Talent Solution.


public static void commuteSearch(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");
  JobQuery jobQuery =
      new JobQuery()
          .setCommuteFilter(
              new CommuteFilter()
                  .setRoadTraffic("TRAFFIC_FREE")
                  .setCommuteMethod("TRANSIT")
                  .setTravelDuration("1000s")
                  .setStartCoordinates(
                      new LatLng().setLatitude(37.422408).setLongitude(-122.085609)));
  if (companyName != null) {
    jobQuery.setCompanyNames(Arrays.asList(companyName));
  }

  SearchJobsRequest searchJobsRequest =
      new SearchJobsRequest()
          .setJobQuery(jobQuery)
          .setRequestMetadata(requestMetadata)
          .setJobView("JOB_VIEW_FULL")
          .setRequirePreciseResultSize(true);
  SearchJobsResponse response =
      talentSolutionClient
          .projects()
          .jobs()
          .search(DEFAULT_PROJECT_ID, searchJobsRequest)
          .execute();
  Thread.sleep(1000);
  System.out.printf("Search jobs for commute results: %s\n", response);
}

Python

Untuk mengetahui informasi lebih lanjut tentang cara menginstal dan membuat klien Cloud Talent Solution, lihat Library Klien Cloud Talent Solution.

def commute_search(client_service, company_name):
    request_metadata = {
        "user_id": "HashedUserId",
        "session_id": "HashedSessionId",
        "domain": "www.google.com",
    }
    start_location = {"latitude": 37.422408, "longitude": -122.085609}
    commute_preference = {
        "road_traffic": "TRAFFIC_FREE",
        "commute_method": "TRANSIT",
        "travel_duration": "1000s",
        "start_coordinates": start_location,
    }
    job_query = {"commute_filter": commute_preference}
    if company_name is not None:
        job_query.update({"company_names": [company_name]})
    request = {
        "job_query": job_query,
        "request_metadata": request_metadata,
        "job_view": "JOB_VIEW_FULL",
        "require_precise_result_size": True,
    }
    response = (
        client_service.projects().jobs().search(parent=parent, body=request).execute()
    )
    print(response)

Go

Untuk mengetahui informasi lebih lanjut tentang cara menginstal dan membuat klien Cloud Talent Solution, lihat Library Klien Cloud Talent Solution.


// commuteSearch searches for jobs within commute filter.
func commuteSearch(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)
	}

	jobQuery := &talent.JobQuery{
		CommuteFilter: &talent.CommuteFilter{
			RoadTraffic:    "TRAFFIC_FREE",
			CommuteMethod:  "TRANSIT",
			TravelDuration: "1000s",
			StartCoordinates: &talent.LatLng{
				Latitude:  37.422408,
				Longitude: -122.085609,
			},
		},
	}
	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",
		RequirePreciseResultSize: true,
	}
	resp, err := service.Projects.Jobs.Search(parent, req).Do()
	if err != nil {
		return nil, fmt.Errorf("failed to search for jobs with commute filter: %w", err)
	}
	return resp, nil
}

Ruby

Untuk mengetahui informasi lebih lanjut tentang cara menginstal dan membuat klien Cloud Talent Solution, lihat Library Klien Cloud Talent Solution.

# project_id              = "Id of the project"
# commute_method          = "The method of transportation for which to calculate the commute time"
# travel_duration         = "The maximum travel time in seconds"
# start_coordinates       = "The latitude and longitude of the location from which to calculate the commute time"

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"
# Set location filter
commute_filter = jobs::CommuteFilter.new road_traffic:      "TRAFFIC_FREE",
                                         commute_method:    commute_method,
                                         travel_duration:   travel_duration,
                                         start_coordinates: start_coordinates
# Perform a search for analyst  related jobs
search_jobs_request =
  jobs::SearchJobsRequest.new request_metadata:            request_metadata,
                              job_query:                   (jobs::JobQuery.new commute_filter: commute_filter),
                              job_view:                    "JOB_VIEW_FULL",
                              require_precise_result_size: true
search_jobs_response = talent_solution_client.search_jobs project_id, search_jobs_request
puts search_jobs_response.to_json
search_jobs_response

Kolom wajib diisi

  • commuteMethod: Metode transportasi yang digunakan untuk menghitung waktu perjalanan. Opsinya adalah DRIVING dan TRANSIT. Semua versi sejak V3p1beta1 juga akan menyertakan mode transit WALKING dan CYCLING. Rute jalan kaki dan bersepeda mungkin tidak mencerminkan kondisi dunia nyata seperti konstruksi atau menyertakan jalur jalan kaki atau bersepeda yang jelas. Respons ini akan menyertakan warnings dalam hasil yang ditampilkan yang harus Anda tampilkan kepada pengguna.

  • travelDuration: Waktu tempuh maksimum dalam detik. Nilai maksimum yang diizinkan adalah 3600s (satu jam). Formatnya adalah 123s.

  • startCoordinates: Lintang dan bujur lokasi asal perhitungan waktu perjalanan. Menerima objek LatLng.

Kolom opsional

  • allowImpreciseAddresses: Alamat "Akurat" ditentukan sebagai alamat tingkat jalan atau koordinat GPS. Jika allowImpreciseAddresses disetel ke true, tugas dengan alamat "tidak akurat" (hanya kota, negara bagian, atau negara) juga dapat ditampilkan. Untuk alamat tingkat kota dan tingkat yang lebih kasar, pencocokan teks digunakan. Jika kolom ini ditetapkan ke false atau tidak ditentukan, hanya tugas yang menyertakan alamat presisi yang ditampilkan oleh penelusuran perjalanan.
  • roadTraffic: Menentukan kepadatan lalu lintas yang akan digunakan saat menghitung waktu perjalanan. Opsinya adalah TRAFFIC_FREE atau BUSY_HOUR. Tidak boleh ada jika departureHourLocal ditentukan.

  • departureTime: Jam keberangkatan yang akan digunakan untuk menghitung dampak lalu lintas. Menerima bilangan bulat antara 0 dan 23, yang merepresentasikan jam di zona waktu startLocation. Tidak boleh ada jika roadTraffic ditentukan.