Search in sources :

Example 1 with CompleteQueryRequest

use of com.google.cloud.talent.v4beta1.CompleteQueryRequest 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)

Aggregations

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