UI에서 통근 조건 검색 구현(v4beta1)

통근 조건 검색을 UI에 통합하면 구직자가 통근 시간으로 설정된 지리적 영역에 있는 채용정보를 검색할 수 있습니다. 통근 조건 검색은 사용자가 선택한 대중교통 모드와 사용자가 통근하는 시간대를 기반으로 통근 시간을 추정합니다.

  1. 통근 조건 검색을 구현하려면 먼저 Cloud Talent Solution을 UI에 연결해야 합니다. Cloud Talent Solution을 설정하려면 <atarget="_blank" class="external" l10n-attrs-original-order="href,target,class" l10n-encrypted-href="I2bjjCb1CfjxAHi33R1uSZFGBtNXMtSEozqMDCbrBLAVTmdE5Zm3DKcU3qbzRuF63VaMACw+gvDqWC/9WAxKePGKDAnihfIk/OpwQPRVH65wl/sHYgP9zxpmH4qLkPOM">빠른 시작 가이드를 따릅니다.</atarget="_blank">

  2. 통근 조건 검색은 CTS 구현 시 사용자가 채용정보와 함께 업로드한 주소 데이터를 사용하여 통근 시간을 계산합니다. 기존 CTS UI에서 이 기능을 사용 설정하려면 jobs.search 요청을 전송하고 JobQuery.commuteFilter 필드에 CommuteFilter 객체를 포함하세요. commuteMethod, travelDuration, startCoordinatesroadTraffic 또는 departureTime은 필수 입력란입니다.

Go

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

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

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	"cloud.google.com/go/talent/apiv4beta1/talentpb"
	"github.com/golang/protobuf/ptypes/duration"
	"google.golang.org/genproto/googleapis/type/latlng"
)

// commuteSearch searches for jobs within commute filter.
func commuteSearch(w io.Writer, projectID, companyID string) error {
	ctx := context.Background()

	// Initialize a jobService client.
	c, err := talent.NewJobClient(ctx)
	if err != nil {
		return fmt.Errorf("talent.NewJobClient: %w", err)
	}
	defer c.Close()

	// Construct a jobQuery request with a commute filter.
	jobQuery := &talentpb.JobQuery{
		CommuteFilter: &talentpb.CommuteFilter{
			CommuteMethod:  talentpb.CommuteMethod_TRANSIT,
			TravelDuration: &duration.Duration{Seconds: 1800},
			StartCoordinates: &latlng.LatLng{
				Latitude:  37.422408,
				Longitude: -122.085609,
			},
		},
	}
	if companyID != "" {
		jobQuery.Companies = []string{fmt.Sprintf("projects/%s/companies/%s", projectID, companyID)}
	}

	// Construct a searchJobs request with a jobQuery.
	req := &talentpb.SearchJobsRequest{
		Parent: fmt.Sprintf("projects/%s", projectID),
		// Make sure to set the RequestMetadata the same as the associated
		// search request.
		RequestMetadata: &talentpb.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,
	}

	resp, err := c.SearchJobs(ctx, req)
	if err != nil {
		return fmt.Errorf("SearchJobs: %w", err)
	}

	for _, job := range resp.GetMatchingJobs() {
		fmt.Fprintf(w, "Matcing Job: %q\n", job.GetJob().GetName())
		fmt.Fprintf(w, "Job address: %v\n", job.GetCommuteInfo().GetJobLocation().GetPostalAddress().GetAddressLines())
	}

	return nil
}

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

UI 권장사항

  1. Cloud Talent Solution에서는 검색 기준으로 거리 (CTS 위치 필터 사용) 통근 시간을 함께 사용할 수 없습니다. 구직자가 두 가지 옵션을 모두 이용할 수 있게 하려면 탭이 두 개인 방식 또는 유사한 방법을 사용하세요.

  2. 백엔드가 구직자의 관련 정보를 통근 필터에 자동으로 채우도록 애플리케이션의 프런트엔드를 수정합니다. 백엔드는 일반 검색 요청과 같은 방식으로 API를 호출합니다.

  3. UI에 항목을 포함하세요.

    • 거리 검색인지 통근 검색인지 선택하는 옵션입니다. 예를 들어 검색 UI가 아래 샘플과 유사할 수 있습니다.

    • 통근 방법 옵션의 드롭다운 메뉴

    • 교통 상태를 조정하는 옵션

    • 총 이동 시간(지원되는 최대 이동 시간은 60분)

    • 통근 시작 시간

  4. 구직자에게 정보를 표시하는 데 API에서 반환되는 통근 시간 정보가 사용됩니다. 지정한 통근 시간 지역 내에 있는 적절한 채용정보만 결과 목록에 반환됩니다. 이 지역 내에서 반환되는 채용정보의 순서와 개수를 조정하는 방법에 대한 설명은 채용정보 검색 권장사항 문서를 참조하세요.

  5. 통근 검색 결과는 실시간 교통상황이 아닌 과거 및 집계된 데이터를 기반으로 합니다. departureTime 교통상황은 지정된 시간대의 평균 교통상황에서 계산됩니다. roadTrafficBUSY_HOUR/TRAFFIC_FREE 옵션은 각각 아침 출근 시간 및 자정의 평균 교통상황입니다. 사용자는 하루 중 어느 시간에 쿼리를 보내든지 동일한 통근 검색 결과를 받습니다.

Google Maps를 이용하여 CTS에서 반환된 통근 시간 정보를 기반으로 지도를 생성하고 이 지도를 구직자에게 반환되는 결과에 포함할 수 있습니다. Maps API 제품군에는 지도 표시와 관련된 몇 가지 옵션이 있습니다. 다른 Maps API 옵션보다 효과적인 Maps API 옵션이 몇 가지 있습니다. 예를 들어 Google 지도 자바스크립트 히트맵 시각화마커 클러스터링을 함께 사용하면 구직자가 설정한 통근 정보를 기준으로 선별된 지역 내에 있는 구직자에게 반환되는 채용정보를 효율적으로 시각화할 수 있습니다. 이와 반대로 경로 모드는 검색 요청에 반환되는 모든 채용정보를 표시하지 않으며 권장 옵션이 아닙니다.

통근 조건에 기반한 검색 구현 방법에 대한 자세한 내용은 통근 조건 검색 안내 가이드를 참조하세요.