Search in sources :

Example 1 with HistogramQuery

use of com.google.cloud.talent.v4.HistogramQuery in project java-talent by googleapis.

the class HistogramSearchJobs method searchJobs.

// Search Jobs with histogram queries.
public static void searchJobs(String projectId, String tenantId, String query) throws IOException {
    // 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 = "http://www.jobUrl.com";
        String sessionId = "Hashed session identifier";
        String userId = "Hashed user identifier";
        RequestMetadata requestMetadata = RequestMetadata.newBuilder().setDomain(domain).setSessionId(sessionId).setUserId(userId).build();
        HistogramQuery histogramQueriesElement = HistogramQuery.newBuilder().setHistogramQuery(query).build();
        SearchJobsRequest request = SearchJobsRequest.newBuilder().setParent(parent.toString()).setRequestMetadata(requestMetadata).addHistogramQueries(histogramQueriesElement).build();
        for (SearchJobsResponse.MatchingJob responseItem : jobServiceClient.searchJobs(request).getMatchingJobsList()) {
            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());
        }
    }
}
Also used : SearchJobsRequest(com.google.cloud.talent.v4.SearchJobsRequest) SearchJobsResponse(com.google.cloud.talent.v4.SearchJobsResponse) TenantName(com.google.cloud.talent.v4.TenantName) HistogramQuery(com.google.cloud.talent.v4.HistogramQuery) JobServiceClient(com.google.cloud.talent.v4.JobServiceClient) Job(com.google.cloud.talent.v4.Job) RequestMetadata(com.google.cloud.talent.v4.RequestMetadata)

Example 2 with HistogramQuery

use of com.google.cloud.talent.v4.HistogramQuery in project java-docs-samples by GoogleCloudPlatform.

the class HistogramSearchJobs method searchJobs.

// Search Jobs with histogram queries.
public static void searchJobs(String projectId, String tenantId, String query) throws IOException {
    // 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 = "http://www.jobUrl.com";
        String sessionId = "Hashed session identifier";
        String userId = "Hashed user identifier";
        RequestMetadata requestMetadata = RequestMetadata.newBuilder().setDomain(domain).setSessionId(sessionId).setUserId(userId).build();
        HistogramQuery histogramQueriesElement = HistogramQuery.newBuilder().setHistogramQuery(query).build();
        SearchJobsRequest request = SearchJobsRequest.newBuilder().setParent(parent.toString()).setRequestMetadata(requestMetadata).addHistogramQueries(histogramQueriesElement).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());
        }
    }
}
Also used : SearchJobsRequest(com.google.cloud.talent.v4beta1.SearchJobsRequest) SearchJobsResponse(com.google.cloud.talent.v4beta1.SearchJobsResponse) TenantName(com.google.cloud.talent.v4beta1.TenantName) HistogramQuery(com.google.cloud.talent.v4beta1.HistogramQuery) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) Job(com.google.cloud.talent.v4beta1.Job) RequestMetadata(com.google.cloud.talent.v4beta1.RequestMetadata)

Example 3 with HistogramQuery

use of com.google.cloud.talent.v4.HistogramQuery in project java-talent by googleapis.

the class JobSearchHistogramSearch method sampleSearchJobs.

/**
 * Search Jobs with histogram queries
 *
 * @param query Histogram query More info on histogram facets, constants, and built-in functions:
 *     https://godoc.org/google.golang.org/genproto/googleapis/cloud/talent/v4beta1#SearchJobsRequest
 */
public static void sampleSearchJobs(String projectId, String tenantId, String query) {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantOrProjectName 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();
        HistogramQuery histogramQueriesElement = HistogramQuery.newBuilder().setHistogramQuery(query).build();
        List<HistogramQuery> histogramQueries = Arrays.asList(histogramQueriesElement);
        SearchJobsRequest request = SearchJobsRequest.newBuilder().setParent(parent.toString()).setRequestMetadata(requestMetadata).addAllHistogramQueries(histogramQueries).build();
        for (SearchJobsResponse.MatchingJob responseItem : jobServiceClient.searchJobs(request).iterateAll()) {
            System.out.printf("Job summary: %s\n", responseItem.getJobSummary());
            System.out.printf("Job title snippet: %s\n", responseItem.getJobTitleSnippet());
            Job job = responseItem.getJob();
            System.out.printf("Job name: %s\n", job.getName());
            System.out.printf("Job title: %s\n", job.getTitle());
        }
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : SearchJobsRequest(com.google.cloud.talent.v4beta1.SearchJobsRequest) HistogramQuery(com.google.cloud.talent.v4beta1.HistogramQuery) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName) Job(com.google.cloud.talent.v4beta1.Job) RequestMetadata(com.google.cloud.talent.v4beta1.RequestMetadata)

Aggregations

HistogramQuery (com.google.cloud.talent.v4beta1.HistogramQuery)2 Job (com.google.cloud.talent.v4beta1.Job)2 JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)2 RequestMetadata (com.google.cloud.talent.v4beta1.RequestMetadata)2 SearchJobsRequest (com.google.cloud.talent.v4beta1.SearchJobsRequest)2 HistogramQuery (com.google.cloud.talent.v4.HistogramQuery)1 Job (com.google.cloud.talent.v4.Job)1 JobServiceClient (com.google.cloud.talent.v4.JobServiceClient)1 RequestMetadata (com.google.cloud.talent.v4.RequestMetadata)1 SearchJobsRequest (com.google.cloud.talent.v4.SearchJobsRequest)1 SearchJobsResponse (com.google.cloud.talent.v4.SearchJobsResponse)1 TenantName (com.google.cloud.talent.v4.TenantName)1 SearchJobsResponse (com.google.cloud.talent.v4beta1.SearchJobsResponse)1 TenantName (com.google.cloud.talent.v4beta1.TenantName)1 TenantOrProjectName (com.google.cloud.talent.v4beta1.TenantOrProjectName)1