职位搜索可以包括一个或多个 JobQuery
过滤器,限制按照位置、公司、薪酬等不同的条件搜索职位。JobQuery
引用中会标记 JobQuery
字段。
位置
通过位置搜索,您可以指定搜索的地理半径或区域。
如需了解详情,请参阅基于位置的搜索。
招聘信息类别
返回属于 Cloud Talent Solution 所标识的特定类别的职位。
类别是预定义的,包括 ACCOUNTING_AND_FINANCE
和 EDUCATION
等。所有类别均由 Cloud Talent Solution 模型确定,建议作为基于类别的属性使用。如需完整列表,请参阅 JobCategory
参考页面。
Java
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
/** Search on category filter. */
public static void categoryFilterSearch(String companyName, List<String> categories)
throws IOException, InterruptedException {
// Make sure to set the requestMetadata the same as the associated search request
RequestMetadata requestMetadata =
new RequestMetadata()
// Make sure to hash your userID
.setUserId("HashedUserId")
// Make sure to hash the sessionID
.setSessionId("HashedSessionID")
// Domain of the website where the search is conducted
.setDomain("www.google.com");
JobQuery jobQuery = new JobQuery().setJobCategories(categories);
if (companyName != null) {
jobQuery.setCompanyNames(Arrays.asList(companyName));
}
SearchJobsRequest searchJobsRequest =
new SearchJobsRequest()
.setRequestMetadata(requestMetadata)
.setJobQuery(jobQuery) // Set the actual search term as defined in the jobQurey
.setSearchMode("JOB_SEARCH"); // Set the search mode to a regular search
SearchJobsResponse searchJobsResponse =
talentSolutionClient
.projects()
.jobs()
.search(DEFAULT_PROJECT_ID, searchJobsRequest)
.execute();
Thread.sleep(1000);
System.out.printf("Category search jobs results: %s\n", searchJobsResponse);
}
Python
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
def category_search(client_service, company_name, categories):
request_metadata = {
"user_id": "HashedUserId",
"session_id": "HashedSessionId",
"domain": "www.google.com",
}
job_query = {"job_categories": categories}
if company_name is not None:
job_query.update({"company_names": [company_name]})
request = {
"search_mode": "JOB_SEARCH",
"request_metadata": request_metadata,
"job_query": job_query,
}
response = (
client_service.projects().jobs().search(parent=parent, body=request).execute()
)
print(response)
Go
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
// categoryFilterSearch searches for jobs on category filter.
func categoryFilterSearch(w io.Writer, projectID, companyName string, categories []string) (*talent.SearchJobsResponse, error) {
ctx := context.Background()
client, err := google.DefaultClient(ctx, talent.CloudPlatformScope)
if err != nil {
return nil, fmt.Errorf("google.DefaultClient: %w", err)
}
// Create the jobs service client.
service, err := talent.New(client)
if err != nil {
return nil, fmt.Errorf("talent.New: %w", err)
}
jobQuery := &talent.JobQuery{
JobCategories: categories,
}
if companyName != "" {
jobQuery.CompanyNames = []string{companyName}
}
parent := "projects/" + projectID
req := &talent.SearchJobsRequest{
// Make sure to set the RequestMetadata the same as the associated
// search request.
RequestMetadata: &talent.RequestMetadata{
// Make sure to hash your userID.
UserId: "HashedUsrId",
// Make sure to hash the sessionID.
SessionId: "HashedSessionId",
// Domain of the website where the search is conducted.
Domain: "www.googlesample.com",
},
// Set the actual search term as defined in the jobQuery.
JobQuery: jobQuery,
// Set the search mode to a regular search.
SearchMode: "JOB_SEARCH",
}
resp, err := service.Projects.Jobs.Search(parent, req).Do()
if err != nil {
return nil, fmt.Errorf("failed to search for jobs with categories %v: %w", categories, err)
}
fmt.Fprintln(w, "Jobs:")
for _, j := range resp.MatchingJobs {
fmt.Fprintf(w, "\t%q\n", j.Job.Name)
}
return resp, nil
}
工作性质
返回属于一个或多个工作性质定义的招聘信息,例如 FULL_TIME
或 VOLUNTEER
。如需查看完整列表,请参阅 EmploymentType 参考页面。
Java
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
/** Search on employment types. */
public static void employmentTypesSearch(String companyName, List<String> employmentTypes)
throws IOException, InterruptedException {
// Make sure to set the requestMetadata the same as the associated search request
RequestMetadata requestMetadata =
new RequestMetadata()
// Make sure to hash your userID
.setUserId("HashedUserId")
// Make sure to hash the sessionID
.setSessionId("HashedSessionID")
// Domain of the website where the search is conducted
.setDomain("www.google.com");
JobQuery jobQuery = new JobQuery().setEmploymentTypes(employmentTypes);
if (companyName != null) {
jobQuery.setCompanyNames(Arrays.asList(companyName));
}
SearchJobsRequest searchJobsRequest =
new SearchJobsRequest()
.setRequestMetadata(requestMetadata)
.setJobQuery(jobQuery) // Set the actual search term as defined in the jobQurey
.setSearchMode("JOB_SEARCH"); // Set the search mode to a regular searchch
SearchJobsResponse searchJobsResponse =
talentSolutionClient
.projects()
.jobs()
.search(DEFAULT_PROJECT_ID, searchJobsRequest)
.execute();
Thread.sleep(1000);
System.out.printf("Employee type search jobs results: %s\n", searchJobsResponse);
}
Python
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
def employment_types_search(client_service, company_name, employment_types):
request_metadata = {
"user_id": "HashedUserId",
"session_id": "HashedSessionId",
"domain": "www.google.com",
}
job_query = {"employment_types": employment_types}
if company_name is not None:
job_query.update({"company_names": [company_name]})
request = {
"search_mode": "JOB_SEARCH",
"request_metadata": request_metadata,
"job_query": job_query,
}
response = (
client_service.projects().jobs().search(parent=parent, body=request).execute()
)
print(response)
Go
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
// employmentTypesSearch searches for jobs on employment types.
func employmentTypesSearch(w io.Writer, projectID, companyName string, employmentTypes []string) (*talent.SearchJobsResponse, error) {
ctx := context.Background()
client, err := google.DefaultClient(ctx, talent.CloudPlatformScope)
if err != nil {
return nil, fmt.Errorf("google.DefaultClient: %w", err)
}
// Create the jobs service client.
service, err := talent.New(client)
if err != nil {
return nil, fmt.Errorf("talent.New: %w", err)
}
jobQuery := &talent.JobQuery{
EmploymentTypes: employmentTypes,
}
if companyName != "" {
jobQuery.CompanyNames = []string{companyName}
}
parent := "projects/" + projectID
req := &talent.SearchJobsRequest{
// Make sure to set the RequestMetadata the same as the associated
// search request.
RequestMetadata: &talent.RequestMetadata{
// Make sure to hash your userID.
UserId: "HashedUsrId",
// Make sure to hash the sessionID.
SessionId: "HashedSessionId",
// Domain of the website where the search is conducted.
Domain: "www.googlesample.com",
},
// Set the actual search term as defined in the jobQuery.
JobQuery: jobQuery,
// Set the search mode to a regular search.
SearchMode: "JOB_SEARCH",
}
resp, err := service.Projects.Jobs.Search(parent, req).Do()
if err != nil {
return nil, fmt.Errorf("failed to search for jobs with employment types %v: %w", employmentTypes, err)
}
fmt.Fprintln(w, "Jobs:")
for _, j := range resp.MatchingJobs {
fmt.Fprintf(w, "\t%q\n", j.Job.Name)
}
return resp, nil
}
日期范围
将搜索限制为在指定日期范围内发布的职位。
publishTimeRange
参考页面列出了可接受的值。
Java
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
/**
* Search on date range. In JSON format, the Timestamp type is encoded as a string in the [RFC
* 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the format is
* "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" e.g. "2017-01-15T01:30:15.01Z"
*/
public static void dateRangeSearch(String companyName, String startTime, String endTime)
throws IOException, InterruptedException {
// Make sure to set the requestMetadata the same as the associated search request
RequestMetadata requestMetadata =
new RequestMetadata()
// Make sure to hash your userID
.setUserId("HashedUserId")
// Make sure to hash the sessionID
.setSessionId("HashedSessionID")
// Domain of the website where the search is conducted
.setDomain("www.google.com");
TimestampRange timestampRange =
new TimestampRange().setStartTime(startTime).setEndTime(endTime);
JobQuery jobQuery = new JobQuery().setPublishTimeRange(timestampRange);
// JobQuery jobQuery = new JobQuery().setPublishTimeRange(dateRange);
if (companyName != null) {
jobQuery.setCompanyNames(Arrays.asList(companyName));
}
SearchJobsRequest searchJobsRequest =
new SearchJobsRequest()
.setRequestMetadata(requestMetadata)
.setJobQuery(jobQuery) // Set the actual search term as defined in the jobQurey
.setSearchMode("JOB_SEARCH"); // Set the search mode to a regular search
SearchJobsResponse searchJobsResponse =
talentSolutionClient
.projects()
.jobs()
.search(DEFAULT_PROJECT_ID, searchJobsRequest)
.execute();
Thread.sleep(1000);
System.out.printf("Search results on jobs with a date range: %s\n", searchJobsResponse);
}
Python
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
def date_range_search(client_service, company_name, date_range):
request_metadata = {
"user_id": "HashedUserId",
"session_id": "HashedSessionId",
"domain": "www.google.com",
}
job_query = {"publish_time_range": date_range}
if company_name is not None:
job_query.update({"company_names": [company_name]})
request = {
"search_mode": "JOB_SEARCH",
"request_metadata": request_metadata,
"job_query": job_query,
}
response = (
client_service.projects().jobs().search(parent=parent, body=request).execute()
)
print(response)
Go
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
// /dateRangeSearch searches for jobs on date range.
// In JSON format, the Timestamp type is encoded as a string in the
// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
// e.g. "2017-01-15T01:30:15.01Z".
func dateRangeSearch(w io.Writer, projectID, companyName, startTime, endTime string) (*talent.SearchJobsResponse, error) {
ctx := context.Background()
client, err := google.DefaultClient(ctx, talent.CloudPlatformScope)
if err != nil {
return nil, fmt.Errorf("google.DefaultClient: %w", err)
}
// Create the jobs service client.
service, err := talent.New(client)
if err != nil {
return nil, fmt.Errorf("talent.New: %w", err)
}
jobQuery := &talent.JobQuery{
PublishTimeRange: &talent.TimestampRange{
StartTime: startTime,
EndTime: endTime,
},
}
if companyName != "" {
jobQuery.CompanyNames = []string{companyName}
}
parent := "projects/" + projectID
req := &talent.SearchJobsRequest{
// Make sure to set the RequestMetadata the same as the associated
// search request.
RequestMetadata: &talent.RequestMetadata{
// Make sure to hash your userID.
UserId: "HashedUsrId",
// Make sure to hash the sessionID.
SessionId: "HashedSessionId",
// Domain of the website where the search is conducted.
Domain: "www.googlesample.com",
},
// Set the actual search term as defined in the jobQuery.
JobQuery: jobQuery,
// Set the search mode to a regular search.
SearchMode: "JOB_SEARCH",
}
resp, err := service.Projects.Jobs.Search(parent, req).Do()
if err != nil {
return nil, fmt.Errorf("failed to search for jobs with date range [%s, %s]: %w", startTime, endTime, err)
}
fmt.Fprintln(w, "Jobs:")
for _, j := range resp.MatchingJobs {
fmt.Fprintf(w, "\t%q\n", j.Job.Name)
}
return resp, nil
}
语言代码
返回与指定语言代码匹配的职位,由招聘信息的 languageCode
字段确定。此字段指定招聘信息帖子的语言,而不是指语言流畅性要求。
Java
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
/** Search on language codes. */
public static void languageCodeSearch(String companyName, List<String> languageCodes)
throws IOException, InterruptedException {
// Make sure to set the requestMetadata the same as the associated search request
RequestMetadata requestMetadata =
new RequestMetadata()
// Make sure to hash your userID
.setUserId("HashedUserId")
// Make sure to hash the sessionID
.setSessionId("HashedSessionID")
// Domain of the website where the search is conducted
.setDomain("www.google.com");
JobQuery jobQuery = new JobQuery().setLanguageCodes(languageCodes);
if (companyName != null) {
jobQuery.setCompanyNames(Arrays.asList(companyName));
}
SearchJobsRequest searchJobsRequest =
new SearchJobsRequest()
.setRequestMetadata(requestMetadata)
.setJobQuery(jobQuery) // Set the actual search term as defined in the jobQurey
.setSearchMode("JOB_SEARCH"); // Set the search mode to a regular search
SearchJobsResponse searchJobsResponse =
talentSolutionClient
.projects()
.jobs()
.search(DEFAULT_PROJECT_ID, searchJobsRequest)
.execute();
Thread.sleep(1000);
System.out.printf("Search results on jobs with a language code: %s\n", searchJobsResponse);
}
Python
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
def language_code_search(client_service, company_name, language_codes):
request_metadata = {
"user_id": "HashedUserId",
"session_id": "HashedSessionId",
"domain": "www.google.com",
}
job_query = {"language_codes": language_codes}
if company_name is not None:
job_query.update({"company_names": [company_name]})
request = {
"search_mode": "JOB_SEARCH",
"request_metadata": request_metadata,
"job_query": job_query,
}
response = (
client_service.projects().jobs().search(parent=parent, body=request).execute()
)
print(response)
Go
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
// languageCodeSearch searches for jobs on language code.
func languageCodeSearch(w io.Writer, projectID, companyName string, languageCodes []string) (*talent.SearchJobsResponse, error) {
ctx := context.Background()
client, err := google.DefaultClient(ctx, talent.CloudPlatformScope)
if err != nil {
return nil, fmt.Errorf("google.DefaultClient: %w", err)
}
// Create the jobs service client.
service, err := talent.New(client)
if err != nil {
return nil, fmt.Errorf("talent.New: %w", err)
}
jobQuery := &talent.JobQuery{
LanguageCodes: languageCodes,
}
if companyName != "" {
jobQuery.CompanyNames = []string{companyName}
}
parent := "projects/" + projectID
req := &talent.SearchJobsRequest{
// Make sure to set the RequestMetadata the same as the associated
// search request.
RequestMetadata: &talent.RequestMetadata{
// Make sure to hash your userID.
UserId: "HashedUsrId",
// Make sure to hash the sessionID.
SessionId: "HashedSessionId",
// Domain of the website where the search is conducted.
Domain: "www.googlesample.com",
},
// Set the actual search term as defined in the jobQuery.
JobQuery: jobQuery,
// Set the search mode to a regular search.
SearchMode: "JOB_SEARCH",
}
resp, err := service.Projects.Jobs.Search(parent, req).Do()
if err != nil {
return nil, fmt.Errorf("failed to search for jobs with languange codes %v: %w", languageCodes, err)
}
fmt.Fprintln(w, "Jobs:")
for _, j := range resp.MatchingJobs {
fmt.Fprintf(w, "\t%q\n", j.Job.Name)
}
return resp, nil
}
公司显示名称
返回 displayName
与所提供的文本字符串匹配的公司的招聘信息。请注意,displayName
是直观易懂的公司名称(例如“Google”),而不是表现为生成的 ID 形式的 name
(例如“companies/80df2034-176e-44a8-b763-b5370f2463a5”)。如需了解名称搜索,请参阅公司显示名称。
您可以使用自动填充建议来提高准确性。
Java
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
/** Search on company display name. */
public static void companyDisplayNameSearch(String companyName, List<String> companyDisplayNames)
throws IOException, InterruptedException {
// Make sure to set the requestMetadata the same as the associated search request
RequestMetadata requestMetadata =
new RequestMetadata()
// Make sure to hash your userID
.setUserId("HashedUserId")
// Make sure to hash the sessionID
.setSessionId("HashedSessionID")
// Domain of the website where the search is conducted
.setDomain("www.google.com");
JobQuery jobQuery = new JobQuery().setCompanyDisplayNames(companyDisplayNames);
if (companyName != null) {
jobQuery.setCompanyNames(Arrays.asList(companyName));
}
SearchJobsRequest searchJobsRequest =
new SearchJobsRequest()
.setRequestMetadata(requestMetadata)
.setJobQuery(jobQuery) // Set the actual search term as defined in the jobQurey
.setSearchMode("JOB_SEARCH"); // Set the search mode to a regular search
SearchJobsResponse searchJobsResponse =
talentSolutionClient
.projects()
.jobs()
.search(DEFAULT_PROJECT_ID, searchJobsRequest)
.execute();
Thread.sleep(1000);
System.out.printf("Search results by display name of company: %s\n", searchJobsResponse);
}
Python
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
def company_display_name_search(client_service, company_name, company_display_names):
request_metadata = {
"user_id": "HashedUserId",
"session_id": "HashedSessionId",
"domain": "www.google.com",
}
job_query = {"company_display_names": company_display_names}
if company_name is not None:
job_query.update({"company_names": [company_name]})
request = {
"search_mode": "JOB_SEARCH",
"request_metadata": request_metadata,
"job_query": job_query,
}
response = (
client_service.projects().jobs().search(parent=parent, body=request).execute()
)
print(response)
Go
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
// companyDisplayNameSearch searches for job on company display names.
func companyDisplayNameSearch(w io.Writer, projectID, companyName string, companyDisplayNames []string) (*talent.SearchJobsResponse, error) {
ctx := context.Background()
client, err := google.DefaultClient(ctx, talent.CloudPlatformScope)
if err != nil {
return nil, fmt.Errorf("google.DefaultClient: %w", err)
}
// Create the jobs service client.
service, err := talent.New(client)
if err != nil {
return nil, fmt.Errorf("talent.New: %w", err)
}
jobQuery := &talent.JobQuery{
CompanyDisplayNames: companyDisplayNames,
}
if companyName != "" {
jobQuery.CompanyNames = []string{companyName}
}
parent := "projects/" + projectID
req := &talent.SearchJobsRequest{
// Make sure to set the RequestMetadata the same as the associated
// search request.
RequestMetadata: &talent.RequestMetadata{
// Make sure to hash your userID.
UserId: "HashedUsrId",
// Make sure to hash the sessionID.
SessionId: "HashedSessionId",
// Domain of the website where the search is conducted.
Domain: "www.googlesample.com",
},
// Set the actual search term as defined in the jobQuery.
JobQuery: jobQuery,
// Set the search mode to a regular search.
SearchMode: "JOB_SEARCH",
}
resp, err := service.Projects.Jobs.Search(parent, req).Do()
if err != nil {
return nil, fmt.Errorf("failed to search for jobs with company display names %v: %w", companyDisplayNames, err)
}
fmt.Fprintln(w, "Jobs:")
for _, j := range resp.MatchingJobs {
fmt.Fprintf(w, "\t%q\n", j.Job.Name)
}
return resp, nil
}
通勤时间
利用通勤时间搜索功能,您可以指定最长的开车或公共交通时间,以便系统返回通勤时间不超过该值的招聘信息。您可以指定使用一天中的哪个时间的流量数据。
如需了解详情,请参阅通勤时间搜索参考页面。
薪酬
根据薪酬金额过滤搜索结果。compensationFilter
如下所示:
"compensationFilter": {
"type": enum(FilterType),
"units": [
enum(CompensationUnit)
],
"range": {
object(CompensationRange)
},
"includeJobWithUnspecifiedCompensationRange": boolean,
}
其中:
type
是必需的,并且指定要搜索的字段。例如,如要搜索按小时付费的招聘信息,请在此处指定UNIT_ONLY
并从compensationUnits
列表中选择HOURLY
。units
是付费频率枚举列表,如HOURLY
和MONTHLY
。如需完整列表,请参阅 CompensationUnit 参考页面。range
指定应返回的最小值和最大值,采用指定的currencyCode
格式(即 3 个字母的货币代码)并按指定的付费频率返回。将currencyCode
保留为空会返回所有招聘信息,而不考虑货币。例如,可通过此过滤器查找时薪介于 10.50 至 15 美元之间的招聘信息。
Java
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
/** Search on compensation. */
public static void compensationSearch(String companyName)
throws IOException, InterruptedException {
// Make sure to set the requestMetadata the same as the associated search request
RequestMetadata requestMetadata =
new RequestMetadata()
// Make sure to hash your userID
.setUserId("HashedUserId")
// Make sure to hash the sessionID
.setSessionId("HashedSessionID")
// Domain of the website where the search is conducted
.setDomain("www.google.com");
// Search jobs that pay between 10.50 and 15 USD per hour
JobQuery jobQuery =
new JobQuery()
.setCompensationFilter(
new CompensationFilter()
.setType("UNIT_AND_AMOUNT")
.setUnits(Arrays.asList("HOURLY"))
.setRange(
new CompensationRange()
.setMaxCompensation(new Money().setCurrencyCode("USD").setUnits(15L))
.setMinCompensation(
new Money()
.setCurrencyCode("USD")
.setUnits(10L)
.setNanos(500000000))));
if (companyName != null) {
jobQuery.setCompanyNames(Arrays.asList(companyName));
}
SearchJobsRequest searchJobsRequest =
new SearchJobsRequest()
.setRequestMetadata(requestMetadata)
.setJobQuery(jobQuery) // Set the actual search term as defined in the jobQurey
.setSearchMode("JOB_SEARCH"); // Set the search mode to a regular search
SearchJobsResponse searchJobsResponse =
talentSolutionClient
.projects()
.jobs()
.search(DEFAULT_PROJECT_ID, searchJobsRequest)
.execute();
Thread.sleep(1000);
System.out.printf("Search results by compensation: %s\n", searchJobsResponse);
}
Python
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
def compensation_search(client_service, company_name):
request_metadata = {
"user_id": "HashedUserId",
"session_id": "HashedSessionId",
"domain": "www.google.com",
}
compensation_range = {
"max_compensation": {"currency_code": "USD", "units": 15},
"min_compensation": {"currency_code": "USD", "units": 10, "nanos": 500000000},
}
compensation_filter = {
"type": "UNIT_AND_AMOUNT",
"units": ["HOURLY"],
"range": compensation_range,
}
job_query = {"compensation_filter": compensation_filter}
if company_name is not None:
job_query.update({"company_names": [company_name]})
request = {
"search_mode": "JOB_SEARCH",
"request_metadata": request_metadata,
"job_query": job_query,
}
response = (
client_service.projects().jobs().search(parent=parent, body=request).execute()
)
print(response)
Go
如需详细了解如何安装和创建 Cloud Talent Solution 客户端,请参阅 Cloud Talent Solution 客户端库。
// compensationSearch searches for job on compensation.
func compensationSearch(w io.Writer, projectID, companyName string) (*talent.SearchJobsResponse, error) {
ctx := context.Background()
client, err := google.DefaultClient(ctx, talent.CloudPlatformScope)
if err != nil {
return nil, fmt.Errorf("google.DefaultClient: %w", err)
}
// Create the jobs service client.
service, err := talent.New(client)
if err != nil {
return nil, fmt.Errorf("talent.New: %w", err)
}
jobQuery := &talent.JobQuery{
CompensationFilter: &talent.CompensationFilter{
Type: "UNIT_AND_AMOUNT",
Units: []string{"HOURLY"},
Range: &talent.CompensationRange{
MaxCompensation: &talent.Money{
Units: 15,
CurrencyCode: "USD",
},
MinCompensation: &talent.Money{
Units: 10,
CurrencyCode: "USD",
Nanos: 500000000,
},
},
},
}
if companyName != "" {
jobQuery.CompanyNames = []string{companyName}
}
parent := "projects/" + projectID
req := &talent.SearchJobsRequest{
// Make sure to set the RequestMetadata the same as the associated
// search request.
RequestMetadata: &talent.RequestMetadata{
// Make sure to hash your userID.
UserId: "HashedUsrId",
// Make sure to hash the sessionID.
SessionId: "HashedSessionId",
// Domain of the website where the search is conducted.
Domain: "www.googlesample.com",
},
// Set the actual search term as defined in the jobQuery.
JobQuery: jobQuery,
// Set the search mode to a regular search.
SearchMode: "JOB_SEARCH",
}
resp, err := service.Projects.Jobs.Search(parent, req).Do()
if err != nil {
return nil, fmt.Errorf("failed to search for jobs with compensation: %w", err)
}
fmt.Fprintln(w, "Jobs:")
for _, j := range resp.MatchingJobs {
fmt.Fprintf(w, "\t%q\n", j.Job.Name)
}
return resp, nil
}
nanos
字段单位为"纳",即 10^-9。1 个单位等于 1000000000 纳。
includeJobWithUnspecifiedCompensationRange
指定是否包含未提供薪酬信息的招聘信息。默认值为 false,不返回未提供薪酬值的招聘信息。
查询语言代码
query_language_code
以 BCP-47 格式指定查询字符串的语言,例如“en-US”。如果留空,则默认值为美国英语。该字段与 languageCode
不相关,后者指定返回的职位列表的语言。如需了解详情,请参阅 JobQuery 文档。示例代码:
"jobQuery":
{"query":"general", "query_language_code":"fr-FR"}}