能否在Google CTS职位搜索中同时检索核心字段与Custom Attribute?
Yes, this is absolutely achievable—you just need to adjust how your custom attributes are configured and how you structure your search queries. Here's what you need to know:
Why Your Current Search Only Hits Core Fields
Right now, your custom attributes are probably not marked as searchable in the CTS index. By default, custom attributes aren't included in text searches unless you explicitly tell CTS to index them for that purpose.
Step 1: Update Custom Attribute Configuration
When creating or updating job postings via the CTS API, add the searchable: true flag to every custom attribute you want included in search results. This tells CTS to index those fields alongside core data like Title, Description, etc.
Example job payload snippet:
{ "title": "Senior Sales Manager", "description": "Lead regional sales operations...", "customAttributes": { "department": { "stringValues": ["Enterprise Sales"], "searchable": true, "filterable": true }, "key_skill": { "stringValues": ["B2B Sales", "Client Negotiation"], "searchable": true } } }
Step 2: Use the Standard Text Search
Once your custom attributes are marked as searchable, the default query parameter in your search request will automatically check all core fields AND all searchable custom attributes. So a search for "Sales" will return jobs where:
- Any core field (Title, Description, Category, Location) matches "Sales", OR
- Any searchable custom attribute (like
departmentorkey_skill) contains "Sales"
Example search request:
{ "query": "Sales", "jobQuery": { "companies": ["projects/your-project/companies/your-company"] } }
Advanced: Explicit Boolean Queries
If you need granular control (e.g., prioritize certain fields or exclude specific attributes), you can use boolean logic in the query parameter to explicitly reference custom attributes:
{ "query": "Sales OR customAttribute:department:Sales OR customAttribute:key_skill:Sales", "jobQuery": { "companies": ["your-company-id"] } }
Critical Reminder
Don't forget to re-index any existing job postings with the updated searchable flag—changes won't apply to old jobs unless you refresh their data in CTS.
内容的提问来源于stack exchange,提问作者Mittal

