통근 조건 검색(v4beta1)

검색 요청에는 출발 지점부터 특정 이동 시간 이내에 포함되는 채용정보만 반환되도록 제한하는 통근 시간 필터가 포함될 수 있습니다. 결과에는 일치하는 채용정보의 예상 통근 시간이 초 단위로 포함됩니다.

특정 통근 시간 이내의 채용정보를 반환하려면 jobs.search 요청을 보내면서 JobQuery.commuteFilter 필드에 CommuteFilter 객체를 포함시켜야 합니다. Cloud Talent Solution은 채용정보의 address를 사용하여 근무처까지 통근하는 데 걸리는 시간을 계산합니다. 상세 주소가 제공되지 않은 경우 Cloud Talent Solution은 근무처의 실제 주소를 유추하려고 시도합니다.

Java

CTS용 클라이언트 라이브러리를 설치하고 사용하는 방법은 CTS 클라이언트 라이브러리를 참조하세요. 자세한 내용은 CTS Java API 참조 문서를 확인하세요.

CTS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.


import com.google.cloud.talent.v4beta1.CommuteFilter;
import com.google.cloud.talent.v4beta1.CommuteMethod;
import com.google.cloud.talent.v4beta1.Job;
import com.google.cloud.talent.v4beta1.JobQuery;
import com.google.cloud.talent.v4beta1.JobServiceClient;
import com.google.cloud.talent.v4beta1.RequestMetadata;
import com.google.cloud.talent.v4beta1.SearchJobsRequest;
import com.google.cloud.talent.v4beta1.SearchJobsResponse;
import com.google.cloud.talent.v4beta1.TenantName;
import com.google.protobuf.Duration;
import com.google.type.LatLng;
import java.io.IOException;

public class CommuteSearchJobs {

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

  // Search Jobs with histogram queries.
  public static void searchJobs(String projectId, String tenantId) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
      TenantName parent = TenantName.of(projectId, tenantId);
      String domain = "www.example.com";
      String sessionId = "Hashed session identifier";
      String userId = "Hashed user identifier";
      RequestMetadata requestMetadata =
          RequestMetadata.newBuilder()
              .setDomain(domain)
              .setSessionId(sessionId)
              .setUserId(userId)
              .build();

      CommuteMethod commuteMethod = CommuteMethod.DRIVING;
      long seconds = 3600L;
      Duration travelDuration = Duration.newBuilder().setSeconds(seconds).build();

      double latitude = 37.422408;
      double longitude = -122.084068;
      LatLng startCoordinates =
          LatLng.newBuilder().setLatitude(latitude).setLongitude(longitude).build();

      CommuteFilter commuteFilter =
          CommuteFilter.newBuilder()
              .setCommuteMethod(commuteMethod)
              .setTravelDuration(travelDuration)
              .setStartCoordinates(startCoordinates)
              .build();

      JobQuery jobQuery = JobQuery.newBuilder().setCommuteFilter(commuteFilter).build();
      SearchJobsRequest request =
          SearchJobsRequest.newBuilder()
              .setParent(parent.toString())
              .setRequestMetadata(requestMetadata)
              .setJobQuery(jobQuery)
              .build();

      for (SearchJobsResponse.MatchingJob responseItem :
          jobServiceClient.searchJobs(request).iterateAll()) {
        System.out.format("Job summary: %s%n", responseItem.getJobSummary());
        System.out.format("Job title snippet: %s%n", responseItem.getJobTitleSnippet());
        Job job = responseItem.getJob();
        System.out.format("Job name: %s%n", job.getName());
        System.out.format("Job title: %s%n", job.getTitle());
      }
    }
  }
}

Java

Cloud Talent Solution 클라이언트 설치 및 만들기에 대한 자세한 내용은 Cloud Talent Solution 클라이언트 라이브러리를 참조하세요.


import com.google.cloud.talent.v4beta1.CommuteFilter;
import com.google.cloud.talent.v4beta1.CommuteMethod;
import com.google.cloud.talent.v4beta1.Job;
import com.google.cloud.talent.v4beta1.JobQuery;
import com.google.cloud.talent.v4beta1.JobServiceClient;
import com.google.cloud.talent.v4beta1.RequestMetadata;
import com.google.cloud.talent.v4beta1.SearchJobsRequest;
import com.google.cloud.talent.v4beta1.SearchJobsResponse;
import com.google.cloud.talent.v4beta1.TenantName;
import com.google.protobuf.Duration;
import com.google.type.LatLng;
import java.io.IOException;

public class CommuteSearchJobs {

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

  // Search Jobs with histogram queries.
  public static void searchJobs(String projectId, String tenantId) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
      TenantName parent = TenantName.of(projectId, tenantId);
      String domain = "www.example.com";
      String sessionId = "Hashed session identifier";
      String userId = "Hashed user identifier";
      RequestMetadata requestMetadata =
          RequestMetadata.newBuilder()
              .setDomain(domain)
              .setSessionId(sessionId)
              .setUserId(userId)
              .build();

      CommuteMethod commuteMethod = CommuteMethod.DRIVING;
      long seconds = 3600L;
      Duration travelDuration = Duration.newBuilder().setSeconds(seconds).build();

      double latitude = 37.422408;
      double longitude = -122.084068;
      LatLng startCoordinates =
          LatLng.newBuilder().setLatitude(latitude).setLongitude(longitude).build();

      CommuteFilter commuteFilter =
          CommuteFilter.newBuilder()
              .setCommuteMethod(commuteMethod)
              .setTravelDuration(travelDuration)
              .setStartCoordinates(startCoordinates)
              .build();

      JobQuery jobQuery = JobQuery.newBuilder().setCommuteFilter(commuteFilter).build();
      SearchJobsRequest request =
          SearchJobsRequest.newBuilder()
              .setParent(parent.toString())
              .setRequestMetadata(requestMetadata)
              .setJobQuery(jobQuery)
              .build();

      for (SearchJobsResponse.MatchingJob responseItem :
          jobServiceClient.searchJobs(request).iterateAll()) {
        System.out.format("Job summary: %s%n", responseItem.getJobSummary());
        System.out.format("Job title snippet: %s%n", responseItem.getJobTitleSnippet());
        Job job = responseItem.getJob();
        System.out.format("Job name: %s%n", job.getName());
        System.out.format("Job title: %s%n", job.getTitle());
      }
    }
  }
}

Python

Cloud Talent Solution 클라이언트 설치 및 만들기에 대한 자세한 내용은 Cloud Talent Solution 클라이언트 라이브러리를 참조하세요.


from google.cloud import talent

def search_jobs(project_id, tenant_id):
    """Search Jobs using commute distance"""

    client = talent.JobServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'

    if isinstance(project_id, bytes):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, bytes):
        tenant_id = tenant_id.decode("utf-8")
    parent = f"projects/{project_id}/tenants/{tenant_id}"
    domain = "www.example.com"
    session_id = "Hashed session identifier"
    user_id = "Hashed user identifier"
    request_metadata = talent.RequestMetadata(
        domain=domain, session_id=session_id, user_id=user_id
    )
    commute_method = talent.CommuteMethod.TRANSIT
    seconds = 1800
    travel_duration = {"seconds": seconds}
    latitude = 37.422408
    longitude = -122.084068
    start_coordinates = {"latitude": latitude, "longitude": longitude}
    commute_filter = talent.CommuteFilter(
        commute_method=commute_method,
        travel_duration=travel_duration,
        start_coordinates=start_coordinates,
    )
    job_query = talent.JobQuery(commute_filter=commute_filter)

    # Iterate over all results
    results = []
    request = talent.SearchJobsRequest(
        parent=parent,
        request_metadata=request_metadata,
        job_query=job_query,
    )
    for response_item in client.search_jobs(request=request).matching_jobs:
        print(f"Job summary: {response_item.job_summary}")
        print(f"Job title snippet: {response_item.job_title_snippet}")
        job = response_item.job
        results.append(job.name)
        print(f"Job name: {job.name}")
        print(f"Job title: {job.title}")
    return results

필수 입력란

  • commuteMethod: 통근 시간을 계산할 교통 수단입니다. 옵션은 DRIVING, TRANSIT, WALKING, CYCLING 대중교통 수단입니다. 도보 및 자전거 경로는 실제 조건(예: 공사 중)을 반영하지 않거나 불분명한 경로를 포함할 수 있습니다. 이러한 응답에는 사용자에게 표시해야 하는 반환된 결과의 warnings가 포함됩니다.

  • travelDuration: 최대 이동 시간(초)입니다. 최대 3600s(1시간)까지 허용됩니다. 형식은 123s입니다.

  • startCoordinates: 통근 시간을 계산하기 시작할 출발지의 위도와 경도입니다. 이 필드는 LatLng 객체를 승인합니다.

  • roadTraffic 또는 departureTime: 통근 검색 결과는 실시간 교통상황이 아닌 과거 및 집계된 데이터를 기반으로 합니다. 사용자는 하루 중 어느 시간에 쿼리를 보내든지 동일한 통근 검색 결과를 받습니다.

    • roadTraffic: 통근 시간을 계산할 때 사용할 교통량을 지정합니다. BUSY_HOUR/TRAFFIC_FREE 옵션은 각각 아침 출근 시간 및 자정에 계산된 평균 교통상황입니다. departureTime이 지정된 경우 이 필드가 없어야 합니다.

    • departureTime: 교통 영향을 계산하는 데 사용할 출발 시간입니다. startLocation의 시간대를 기준으로 시간을 나타내는 0~23 범위의 정수를 사용합니다. 교통상황은 지정된 시간대의 평균 교통상황에서 계산됩니다. roadTraffic이 지정된 경우 이 필드가 없어야 합니다.

선택 필드

  • allowImpreciseAddresses: 'precise' 주소는 도로명 주소 또는 GPS 좌표로 정의됩니다. allowImpreciseAddressestrue로 설정하면 'imprecise' 주소(시, 도 또는 국가만)가 있는 채용정보도 반환될 수 있습니다. 도시 수준과 그보다 큰 단위의 주소의 경우 API는 텍스트 일치를 사용하여 결과를 반환합니다. 이 필드를 false로 설정하거나 지정하지 않으면 precise 주소를 포함하는 채용정보만 반환합니다.