Problem/Motivation
Vertex supports returning all the facet keys for a given facet with their counts when returning search results from an Advanced Website Index. This information is critical for enabling faceting UIs. Currently the module doesn't support requesting the FacetSpec.
There may be other features that the module does not currently support that would require altering the request.
Proposed resolution
Allow altering the request and results in a separate module. This would allow for adding functionality such as requesting and parsing facetSpecs in another module.
Add a checkbox "Enable Faceting" within Filter Expressions that only appears when "Enable Filter" is checked and a Filter Plugin is selected.
When this checkbox is checked, expose a multi-value field to define facet keys.
Optionally also expose a text field that accepts an integer for limit (how many values to return for each key) If the limit field is left blank, would default to 20 to match the FacetSpec documentation.
Or - simply set the max = to the max for FacetSpec (300).
If "Enable Faceting" is checked, and there is at least one key, add facetSpecs to the query.
curl -X POST -H "Authorization: Bearer $( gcloud auth print-access-token ) " -H "Content-Type: application/json" "https://discoveryengine.googleapis.com/v1/projects/[project]/locations/global/collections/default_collection/engines/[search_app]/servingConfigs/default_search:search" -d '{ "query": "keyword", "filter": "datePublished >= \"2026-04-09\"", "facetSpecs": [{"facetKey":{"key": "about"}, "limit":50}]}'
Issue fork vertex_ai_search-3596656
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
jastraat commentedCurrently just setting the limit of facet keys to the max 300 but this could be configurable.
Comment #4
jastraat commentedComment #5
jastraat commentedAs an alternative approach, add the ability to alter the request and parse results in a separate module. The facet functionality could then live in a submodule if desired.
Comment #6
jastraat commentedComment #7
jastraat commentedComment #8
jastraat commentedComment #9
jastraat commentedComment #11
timozura commented