Cloud Talent Solution provides autocomplete suggestions for job titles and
company names. Only active job postings and companies with at least one open
job are considered eligible for suggestion results. Once a new job or company
is added, it takes up to 48 hours for the information to be added to the
autocomplete result set.

To use autocomplete, call the [`complete`](https://docs.cloud.google.com/talent-solution/job-search/v3/docs/reference/rest/v3/projects/complete.md.txt) method when the search bar is updated.

> [!NOTE]
> **Note:** Language codes must be specified using the [BCP-47](https://tools.ietf.org/html/bcp47) identifier. For example: `en-US` or `zh-TW`. Do not use abbreviated language codes such as `en` or `zh`.

### Java


For more on installing and creating a Cloud Talent Solution client, see
[Cloud Talent Solution Client Libraries](https://docs.cloud.google.com/talent-solution/job-search/v3/docs/libraries.md.txt).

```java

/** Auto completes job titles within given companyName. */
public static void jobTitleAutoComplete(String companyName, String query) throws IOException {

  Complete complete =
      talentSolutionClient
          .projects()
          .complete(DEFAULT_PROJECT_ID)
          .setQuery(query)
          .setLanguageCode("en-US")
          .setType("JOB_TITLE")
          .setPageSize(10);
  if (companyName != null) {
    complete.setCompanyName(companyName);
  }

  CompleteQueryResponse results = complete.execute();

  System.out.println(results);
}
```

### Python


For more on installing and creating a Cloud Talent Solution client, see
[Cloud Talent Solution Client Libraries](https://docs.cloud.google.com/talent-solution/job-search/v3/docs/libraries.md.txt).

```python
def job_title_auto_complete(client_service, query, company_name):
    complete = client_service.projects().complete(
        name=name, query=query, languageCode="en-US", type="JOB_TITLE", pageSize=10
    )
    if company_name is not None:
        complete.companyName = company_name

    results = complete.execute()
    print(results)

```

### Node.js


For more on installing and creating a Cloud Talent Solution client, see
[Cloud Talent Solution Client Libraries](https://docs.cloud.google.com/talent-solution/job-search/v3/docs/libraries.md.txt).

```javascript

const talent = require('@google-cloud/talent').v4;

/**
 * Complete job title given partial text (autocomplete)
 *
 * @param projectId {string} Your Google Cloud Project ID
 * @param tenantId {string} Identifier of the TenantId
 */
function sampleCompleteQuery(
  projectId,
  tenantId,
  query,
  numResults,
  languageCode
) {
  const client = new talent.CompletionClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const query = '[partially typed job title]';
  // const numResults = 5;
  // const languageCode = 'en-US';
  const formattedParent = client.tenantPath(projectId, tenantId);
  const languageCodes = [languageCode];
  const request = {
    parent: formattedParent,
    query: query,
    pageSize: numResults,
    languageCodes: languageCodes,
  };
  client
    .completeQuery(request)
    .then(responses => {
      const response = responses[0];
      for (const result of response.completionResults) {
        console.log(`Suggested title: ${result.suggestion}`);
        // Suggestion type is JOB_TITLE or COMPANY_TITLE
        console.log(`Suggestion type: ${result.type}`);
      }
    })
    .catch(err => {
      console.error(err);
    });
}
```

<br />