Stay organized with collections
Save and categorize content based on your preferences.
You can get a histogram representation of the number of
jobs associated with a given search. A search request, with
histogram facets set, returns the search results and a count of all the
jobs that match a particular query, broken down by the requested searchType.
For example, a histogram search could return the number of jobs per employment
type (full-time, part-time, and so on) from a customer's set of jobs.
The Cloud Talent Solution Beta release (v3p1beta1) allows you to define histograms
in a less structured, more flexible, and more intuitive way. The histogram
representations do not change.
Benefits
The new structure of the histogram queries offers developers more intuitive ways
of defining histogram requests, while also providing more clarity into the
definition of buckets, ranges, etc.
Usage
The new histogram part of the search query replaces the old structured
fields for defining the histogram.
Code Samples
The following code sample returns histogram results.
The histogramQuery field is now a single string field that is an expression
that defines the histogram. For details on the functions available for
histogram queries, see HistogramQuery.
/** Histogram search */publicstaticvoidhistogramSearch(StringcompanyName)throwsIOException,InterruptedException{// Make sure to set the requestMetadata the same as the associated search requestRequestMetadatarequestMetadata=newRequestMetadata()// 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");HistogramFacetshistogramFacets=newHistogramFacets().setSimpleHistogramFacets(Arrays.asList("COMPANY_ID")).setCustomAttributeHistogramFacets(Arrays.asList(newCustomAttributeHistogramRequest().setKey("someFieldName1").setStringValueHistogram(true)));// conducted.SearchJobsRequestsearchJobsRequest=newSearchJobsRequest().setRequestMetadata(requestMetadata).setSearchMode("JOB_SEARCH").setHistogramFacets(histogramFacets);if(companyName!=null){searchJobsRequest.setJobQuery(newJobQuery().setCompanyNames(Arrays.asList(companyName)));}SearchJobsResponsesearchJobsResponse=talentSolutionClient.projects().jobs().search(DEFAULT_PROJECT_ID,searchJobsRequest).execute();Thread.sleep(1000);System.out.printf("Histogram search results: %s\n",searchJobsResponse);}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Histogram (v3)\n\nYou can get a histogram representation of the number of\njobs associated with a given search. A search request, with\nhistogram facets set, returns the search results and a count of all the\njobs that match a particular query, broken down by the requested [searchType](/talent-solution/job-search/v3/docs/reference/rest/v3/SearchType).\n\nFor example, a histogram search could return the number of jobs per employment\ntype (full-time, part-time, and so on) from a customer's set of jobs.\n\nThe Cloud Talent Solution Beta release (v3p1beta1) allows you to define histograms\nin a less structured, more flexible, and more intuitive way. The histogram\nrepresentations do not change.\n\nBenefits\n--------\n\nThe new structure of the histogram queries offers developers more intuitive ways\nof defining histogram requests, while also providing more clarity into the\ndefinition of buckets, ranges, etc.\n\nUsage\n-----\n\nThe new histogram part of the search query replaces the old structured\nfields for defining the histogram.\n| **Note:** Having both versions in the same search request causes an error with HTTP response code 400.\n\nCode Samples\n------------\n\nThe following code sample returns histogram results.\n\nThe `histogramQuery` field is now a single string field that is an expression\nthat defines the histogram. For details on the functions available for\nhistogram queries, see [`HistogramQuery`](/talent-solution/job-search/v3/docs/reference/rest/v3p1beta1/HistogramQuery). \n\n### Java\n\n\nFor more on installing and creating a Cloud Talent Solution client, refer to\n[Cloud Talent Solution Client Libraries](/talent-solution/job-search/v3/docs/libraries).\n\n### Java\n\n\nTo authenticate to CTS, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n /** Histogram search */\n public static void histogramSearch(String companyName) throws IOException, InterruptedException {\n // Make sure to set the requestMetadata the same as the associated search request\n RequestMetadata requestMetadata =\n new RequestMetadata()\n // Make sure to hash your userID\n .setUserId(\"HashedUserId\")\n // Make sure to hash the sessionID\n .setSessionId(\"HashedSessionID\")\n // Domain of the website where the search is conducted\n .setDomain(\"www.google.com\");\n\n HistogramFacets histogramFacets =\n new HistogramFacets()\n .setSimpleHistogramFacets(Arrays.asList(\"COMPANY_ID\"))\n .setCustomAttributeHistogramFacets(\n Arrays.asList(\n new CustomAttributeHistogramRequest()\n .setKey(\"someFieldName1\")\n .setStringValueHistogram(true)));\n\n // conducted.\n SearchJobsRequest searchJobsRequest =\n new SearchJobsRequest()\n .setRequestMetadata(requestMetadata)\n .setSearchMode(\"JOB_SEARCH\")\n .setHistogramFacets(histogramFacets);\n if (companyName != null) {\n searchJobsRequest.setJobQuery(new JobQuery().setCompanyNames(Arrays.asList(companyName)));\n }\n\n SearchJobsResponse searchJobsResponse =\n talentSolutionClient\n .projects()\n .jobs()\n .search(DEFAULT_PROJECT_ID, searchJobsRequest)\n .execute();\n Thread.sleep(1000);\n\n System.out.printf(\"Histogram search results: %s\\n\", searchJobsResponse);\n }\n\n### Python\n\n\nFor more on installing and creating a Cloud Talent Solution client, refer to\n[Cloud Talent Solution Client Libraries](/talent-solution/job-search/v3/docs/libraries).\n\n### Python\n\n\nTo authenticate to CTS, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n def histogram_search(client_service, company_name):\n request_metadata = {\n \"user_id\": \"HashedUserId\",\n \"session_id\": \"HashedSessionId\",\n \"domain\": \"www.google.com\",\n }\n custom_attribute_histogram_facet = {\n \"key\": \"someFieldName1\",\n \"string_value_histogram\": True,\n }\n histogram_facets = {\n \"simple_histogram_facets\": [\"COMPANY_ID\"],\n \"custom_attribute_histogram_facets\": [custom_attribute_histogram_facet],\n }\n request = {\n \"search_mode\": \"JOB_SEARCH\",\n \"request_metadata\": request_metadata,\n \"histogram_facets\": histogram_facets,\n }\n if company_name is not None:\n request.update({\"job_query\": {\"company_names\": [company_name]}})\n response = (\n client_service.projects().jobs().search(parent=parent, body=request).execute()\n )\n print(response)\n\n\u003cbr /\u003e"]]