Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate code from googleapis/java-talent #7402

Merged
merged 93 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from 92 commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
96f2f31
samples: add generated samples (#67)
yoshi-automation Feb 5, 2020
7836c01
samples: move generated samples to generated directory (#80)
chingor13 Feb 24, 2020
5948f75
samples: scaffold pom.xml files (#95)
yoshi-automation Mar 17, 2020
2ec08db
chore(deps): update dependency com.google.cloud:libraries-bom to v4.3…
renovate-bot Mar 23, 2020
6117aa0
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Mar 26, 2020
f4f4e72
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Mar 30, 2020
20f829e
chore(deps): update dependency com.google.cloud:libraries-bom to v4.4…
renovate-bot Apr 1, 2020
e769f57
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Apr 6, 2020
a993237
chore(deps): update dependency com.google.cloud:libraries-bom to v4.4…
renovate-bot Apr 6, 2020
36b79cb
chore(deps): update dependency com.google.cloud:libraries-bom to v5 (…
renovate-bot Apr 14, 2020
d9796d9
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Apr 16, 2020
76ab880
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Apr 17, 2020
ad27968
chore(deps): update dependency com.google.cloud:libraries-bom to v5.2…
renovate-bot Apr 23, 2020
21266fd
chore(deps): update dependency com.google.cloud:libraries-bom to v5.3…
renovate-bot Apr 28, 2020
caea276
chore(deps): update dependency com.google.cloud:libraries-bom to v5.4…
renovate-bot May 19, 2020
84f9ede
chore(deps): update dependency com.google.cloud:libraries-bom to v5.5…
renovate-bot May 29, 2020
a09b521
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Jun 10, 2020
052c856
chore(deps): update dependency com.google.cloud:libraries-bom to v5.7…
renovate-bot Jun 10, 2020
5102000
chore(deps): update dependency com.google.cloud:libraries-bom to v6 (…
renovate-bot Jun 16, 2020
50d25c7
chore(deps): update dependency com.google.cloud:libraries-bom to v7 (…
renovate-bot Jun 17, 2020
6898dec
chore(deps): update dependency com.google.cloud:libraries-bom to v7.0…
renovate-bot Jun 22, 2020
e189725
chore(deps): update dependency com.google.cloud:libraries-bom to v8 (…
renovate-bot Jun 26, 2020
a5ec5b1
chore(deps): update dependency com.google.cloud:libraries-bom to v8.1…
renovate-bot Jul 16, 2020
1af22ad
chore(deps): update dependency com.google.cloud:libraries-bom to v10 …
renovate-bot Sep 9, 2020
346b44c
chore(deps): update dependency com.google.cloud:libraries-bom to v10.…
renovate-bot Sep 9, 2020
df5402c
chore(deps): update dependency com.google.cloud:libraries-bom to v11 …
renovate-bot Sep 24, 2020
930b111
chore(deps): update dependency com.google.cloud:libraries-bom to v11.…
renovate-bot Oct 1, 2020
d19fca7
chore(deps): update dependency com.google.cloud:libraries-bom to v12 …
renovate-bot Oct 6, 2020
cdd28d1
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Oct 9, 2020
63bd2e2
test(deps): update dependency junit:junit to v4.13.1
renovate-bot Oct 12, 2020
62438ad
samples: add Job Search v4 samples (#275)
saumyasahu-bot Oct 14, 2020
115d637
chore(deps): update dependency com.google.cloud:libraries-bom to v12.…
renovate-bot Oct 15, 2020
f55d72f
chore(deps): update dependency com.google.cloud:libraries-bom to v13 …
renovate-bot Oct 20, 2020
7cc284c
chore(deps): update dependency com.google.cloud:libraries-bom to v13.…
renovate-bot Oct 21, 2020
d23719b
test(deps): update dependency com.google.truth:truth to v1.1 (#292)
renovate-bot Oct 22, 2020
75dc820
chore(deps): update dependency com.google.cloud:libraries-bom to v13.…
renovate-bot Oct 23, 2020
fddd568
chore(deps): update dependency com.google.cloud:libraries-bom to v13.…
renovate-bot Oct 27, 2020
5052c02
chore(deps): update dependency com.google.cloud:libraries-bom to v13.…
renovate-bot Oct 30, 2020
6cd8021
chore(deps): update dependency com.google.cloud:libraries-bom to v14 …
renovate-bot Nov 4, 2020
11ea366
chore(deps): update dependency com.google.cloud:libraries-bom to v15 …
renovate-bot Nov 5, 2020
87e072d
chore(deps): update dependency com.google.cloud:libraries-bom to v16 …
renovate-bot Nov 19, 2020
b555461
chore(deps): update dependency com.google.cloud:libraries-bom to v16.…
renovate-bot Dec 15, 2020
ab17da2
chore(deps): update dependency com.google.cloud:libraries-bom to v16.…
renovate-bot Jan 7, 2021
d8d6167
chore(deps): update dependency com.google.cloud:libraries-bom to v16.…
renovate-bot Jan 20, 2021
f88d189
test(deps): update dependency com.google.truth:truth to v1.1.2 (#393)
renovate-bot Jan 25, 2021
adb8241
test(deps): update dependency junit:junit to v4.13.2 (#411)
renovate-bot Feb 19, 2021
d5f6707
chore(deps): update dependency com.google.cloud:libraries-bom to v17 …
renovate-bot Feb 24, 2021
1cf474e
chore(deps): update dependency com.google.cloud:libraries-bom to v18 …
renovate-bot Feb 25, 2021
a897821
chore(deps): update dependency com.google.cloud:libraries-bom to v19 …
renovate-bot Mar 4, 2021
8001750
chore(deps): update dependency com.google.cloud:libraries-bom to v19.…
renovate-bot Mar 29, 2021
a462f1f
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Apr 9, 2021
e404d92
chore(deps): update dependency com.google.cloud:libraries-bom to v20 …
renovate-bot Apr 12, 2021
eb36e56
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot Apr 19, 2021
976792e
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot Apr 29, 2021
dcfba6f
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot May 13, 2021
ff9010a
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot May 17, 2021
21581a7
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot May 25, 2021
ad3e609
test(deps): update dependency com.google.truth:truth to v1.1.3 (#521)
renovate-bot May 26, 2021
73354e2
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot Jun 7, 2021
92ff1f4
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Jun 7, 2021
f8791a2
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot Jun 23, 2021
2cfaad8
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot Jul 9, 2021
a904e82
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot Jul 27, 2021
f516fe8
chore(deps): update dependency com.google.cloud:libraries-bom to v21 …
renovate-bot Aug 19, 2021
2ec5e29
chore(deps): update dependency com.google.cloud:libraries-bom to v22 …
renovate-bot Aug 27, 2021
38d25f4
chore: migrate to owlbot (#606)
Neenu1995 Sep 5, 2021
05f4eb2
chore(deps): update dependency com.google.cloud:libraries-bom to v23 …
renovate-bot Sep 13, 2021
54848bf
feat: Added a new `KeywordMatchMode` field to support more keyword ma…
gcf-owl-bot[bot] Sep 20, 2021
5915591
chore(deps): update dependency com.google.cloud:libraries-bom to v23.…
renovate-bot Oct 1, 2021
b9953d5
chore(deps): update dependency com.google.cloud:libraries-bom to v24 …
renovate-bot Oct 27, 2021
5188111
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Dec 6, 2021
afc51f4
chore(deps): update dependency com.google.cloud:libraries-bom to v24.…
renovate-bot Dec 8, 2021
8a33621
chore(deps): update dependency com.google.cloud:libraries-bom to v24.…
renovate-bot Dec 28, 2021
204e70d
chore(deps): update dependency com.google.cloud:libraries-bom to v24.…
renovate-bot Jan 7, 2022
f546fc4
chore(deps): update dependency com.google.cloud:libraries-bom to v24.…
renovate-bot Jan 18, 2022
48aea92
chore(deps): update dependency com.google.cloud:libraries-bom to v24.…
renovate-bot Feb 8, 2022
6bb3b3f
chore(deps): update dependency com.google.cloud:libraries-bom to v24.…
renovate-bot Mar 3, 2022
bfab223
chore(deps): update dependency com.google.cloud:libraries-bom to v25 …
renovate-bot Mar 14, 2022
064c64c
test: fix sample test (#762)
eaball35 Mar 22, 2022
b911760
chore(deps): update dependency com.google.cloud:libraries-bom to v25.…
renovate-bot Apr 1, 2022
b93a5dd
chore(deps): update dependency com.google.cloud:libraries-bom to v25.…
renovate-bot Apr 27, 2022
d7b98da
chore: remove legacy generated samples (#783)
eaball35 May 13, 2022
85911f5
chore(deps): update dependency com.google.cloud:libraries-bom to v25.…
renovate-bot May 16, 2022
8f39373
chore(deps): update dependency com.google.cloud:libraries-bom to v25.…
renovate-bot Jun 6, 2022
ee34a04
chore(deps): update dependency com.google.cloud:libraries-bom to v26 …
renovate-bot Jul 11, 2022
b4ad759
chore(deps): update dependency com.google.cloud:libraries-bom to v26.…
renovate-bot Aug 16, 2022
008ba0b
chore(deps): update dependency com.google.cloud:libraries-bom to v26.…
renovate-bot Aug 31, 2022
58332c4
chore(deps): update dependency com.google.cloud:libraries-bom to v26.…
renovate-bot Sep 20, 2022
ea056e8
chore(deps): update dependency com.google.cloud:libraries-bom to v26.…
renovate-bot Oct 7, 2022
d9af863
chore(deps): update dependency com.google.cloud:libraries-bom to v26.…
renovate-bot Nov 8, 2022
9c5ef07
Merge remote-tracking branch 'migration/main' into java-talent-migration
charlieyu1996 Nov 10, 2022
e86fcb2
Update JobSearchCreateClientEvent.java
charlieyu1996 Nov 10, 2022
c1011f3
Update pom.xml
charlieyu1996 Nov 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions talent/snippets/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version='1.0' encoding='UTF-8'?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud</groupId>
<artifactId>talent-snippets</artifactId>
<packaging>jar</packaging>
<name>Google Talent Solution Snippets</name>
<url>https://github.com/googleapis/java-talent</url>

<!--
The parent pom defines common style checks and testing strategies for our samples.
Removing or replacing it should not affect the execution of the samples in anyway.
-->
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.2.0</version>
</parent>

<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>


<!-- [START talent_install_with_bom] -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.1.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-talent</artifactId>
</dependency>
<!-- [END talent_install_with_bom] -->

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>1.1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.jobs;

// [START job_search_commute_search]

import com.google.cloud.talent.v4.CommuteFilter;
import com.google.cloud.talent.v4.CommuteMethod;
import com.google.cloud.talent.v4.Job;
import com.google.cloud.talent.v4.JobQuery;
import com.google.cloud.talent.v4.JobServiceClient;
import com.google.cloud.talent.v4.RequestMetadata;
import com.google.cloud.talent.v4.SearchJobsRequest;
import com.google.cloud.talent.v4.SearchJobsResponse;
import com.google.cloud.talent.v4.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).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());
}
}
}
}
// [END job_search_commute_search]
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.jobs;

// [START job_search_custom_ranking_search]

import com.google.cloud.talent.v4.Job;
import com.google.cloud.talent.v4.JobServiceClient;
import com.google.cloud.talent.v4.RequestMetadata;
import com.google.cloud.talent.v4.SearchJobsRequest;
import com.google.cloud.talent.v4.SearchJobsResponse;
import com.google.cloud.talent.v4.TenantName;
import java.io.IOException;

public class CustomRankingSearchJobs {

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

// Search Jobs using custom rankings.
public static void searchCustomRankingJobs(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();
SearchJobsRequest.CustomRankingInfo.ImportanceLevel importanceLevel =
SearchJobsRequest.CustomRankingInfo.ImportanceLevel.EXTREME;
String rankingExpression = "(someFieldLong + 25) * 0.25";
SearchJobsRequest.CustomRankingInfo customRankingInfo =
SearchJobsRequest.CustomRankingInfo.newBuilder()
.setImportanceLevel(importanceLevel)
.setRankingExpression(rankingExpression)
.build();
String orderBy = "custom_ranking desc";
SearchJobsRequest request =
SearchJobsRequest.newBuilder()
.setParent(parent.toString())
.setRequestMetadata(requestMetadata)
.setCustomRankingInfo(customRankingInfo)
.setOrderBy(orderBy)
.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());
}
}
}
}
// [END job_search_custom_ranking_search]
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.jobs;

// [START job_search_histogram_search]

import com.google.cloud.talent.v4.HistogramQuery;
import com.google.cloud.talent.v4.Job;
import com.google.cloud.talent.v4.JobServiceClient;
import com.google.cloud.talent.v4.RequestMetadata;
import com.google.cloud.talent.v4.SearchJobsRequest;
import com.google.cloud.talent.v4.SearchJobsResponse;
import com.google.cloud.talent.v4.TenantName;
import java.io.IOException;

public class HistogramSearchJobs {

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";
String query = "count(base_compensation, [bucket(12, 20)])";
searchJobs(projectId, tenantId, query);
}

// Search Jobs with histogram queries.
public static void searchJobs(String projectId, String tenantId, String query)
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 = "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());
}
}
}
}
// [END job_search_histogram_search]
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.jobs;

// [START job_search_autocomplete_job_title]

import com.google.cloud.talent.v4.CompleteQueryRequest;
import com.google.cloud.talent.v4.CompleteQueryResponse;
import com.google.cloud.talent.v4.CompletionClient;
import com.google.cloud.talent.v4.TenantName;
import java.io.IOException;

public class JobSearchAutoCompleteJobTitle {

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

// Complete job title given partial text (autocomplete).
public static void completeQuery(String projectId, String tenantId, String query)
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 (CompletionClient completionClient = CompletionClient.create()) {
TenantName parent = TenantName.of(projectId, tenantId);
CompleteQueryRequest request =
CompleteQueryRequest.newBuilder()
.setTenant(parent.toString())
.setQuery(query)
.setPageSize(5) // limit for number of results
.addLanguageCodes("en-US") // language code
.build();
CompleteQueryResponse response = completionClient.completeQuery(request);
for (CompleteQueryResponse.CompletionResult result : response.getCompletionResultsList()) {
System.out.format("Suggested title: %s%n", result.getSuggestion());
// Suggestion type is JOB_TITLE or COMPANY_TITLE
System.out.format("Suggestion type: %s%n", result.getType());
}
}
}
}
// [END job_search_autocomplete_job_title]
Loading