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());
}
}
}
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());
}
}
}
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);
}
}
Aggregations