Search in sources :

Example 1 with CompletionClient

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

the class JobSearchAutoCompleteJobTitle method completeQuery.

// Complete job title given partial text (autocomplete).
public static void completeQuery(String projectId, String tenantId, String query) throws IOException {
    // 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().setParent(parent.toString()).setQuery(query).setPageSize(// limit for number of results
        5).addLanguageCodes(// language code
        "en-US").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());
        }
    }
}
Also used : CompleteQueryResponse(com.google.cloud.talent.v4beta1.CompleteQueryResponse) TenantName(com.google.cloud.talent.v4beta1.TenantName) CompletionClient(com.google.cloud.talent.v4beta1.CompletionClient) CompleteQueryRequest(com.google.cloud.talent.v4beta1.CompleteQueryRequest)

Example 2 with CompletionClient

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

the class JobSearchAutocompleteJobTitle method sampleCompleteQuery.

/**
 * Complete job title given partial text (autocomplete)
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenantd
 */
public static void sampleCompleteQuery(String projectId, String tenantId, String query, int numResults, String languageCode) {
    try (CompletionClient completionClient = CompletionClient.create()) {
        TenantOrProjectName parent = TenantName.of(projectId, tenantId);
        List<String> languageCodes = Arrays.asList(languageCode);
        CompleteQueryRequest request = CompleteQueryRequest.newBuilder().setParent(parent.toString()).setQuery(query).setPageSize(numResults).addAllLanguageCodes(languageCodes).build();
        CompleteQueryResponse response = completionClient.completeQuery(request);
        for (CompleteQueryResponse.CompletionResult result : response.getCompletionResultsList()) {
            System.out.printf("Suggested title: %s\n", result.getSuggestion());
            // Suggestion type is JOB_TITLE or COMPANY_TITLE
            System.out.printf("Suggestion type: %s\n", result.getType());
        }
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : CompleteQueryResponse(com.google.cloud.talent.v4beta1.CompleteQueryResponse) CompletionClient(com.google.cloud.talent.v4beta1.CompletionClient) CompleteQueryRequest(com.google.cloud.talent.v4beta1.CompleteQueryRequest) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName)

Example 3 with CompletionClient

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

the class JobSearchAutoCompleteJobTitle method completeQuery.

// Complete job title given partial text (autocomplete).
public static void completeQuery(String projectId, String tenantId, String query) throws IOException {
    // 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(// limit for number of results
        5).addLanguageCodes(// language code
        "en-US").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());
        }
    }
}
Also used : CompleteQueryResponse(com.google.cloud.talent.v4.CompleteQueryResponse) TenantName(com.google.cloud.talent.v4.TenantName) CompletionClient(com.google.cloud.talent.v4.CompletionClient) CompleteQueryRequest(com.google.cloud.talent.v4.CompleteQueryRequest)

Aggregations

CompleteQueryRequest (com.google.cloud.talent.v4beta1.CompleteQueryRequest)2 CompleteQueryResponse (com.google.cloud.talent.v4beta1.CompleteQueryResponse)2 CompletionClient (com.google.cloud.talent.v4beta1.CompletionClient)2 CompleteQueryRequest (com.google.cloud.talent.v4.CompleteQueryRequest)1 CompleteQueryResponse (com.google.cloud.talent.v4.CompleteQueryResponse)1 CompletionClient (com.google.cloud.talent.v4.CompletionClient)1 TenantName (com.google.cloud.talent.v4.TenantName)1 TenantName (com.google.cloud.talent.v4beta1.TenantName)1 TenantOrProjectName (com.google.cloud.talent.v4beta1.TenantOrProjectName)1