Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How facets can be filtered based on query for GCP Vertex API Search approach

Hi Team,

We created a search using the Google console API approach and noticed that the facets are static and are not filtered dynamically based on the given query.
Below are the details of the API call:

https://discoveryengine.googleapis.com/v1alpha/projects/******-dev-417***/locations/global/collectio...
Please let us know if there is any route to filter the facet values based on a query.

Thanks 
Prem

Solved Solved
0 2 175
1 ACCEPTED SOLUTION

Hi @PremKolli ,

To filter the facet values dynamically based on the selected facets, the Google API returns a facet object in the response, which updates the facet values for the query. If any particular facet is selected, the facet object reflects the changes.

If you need the facet response object, you will need to send a facets payload to the API, specifying the facet names for which you want the values. With each API call, you can use the facets object to dynamically update the facet values.

Below is an example of the facet payload:

```json

facetSpecs: [
          {
            facetKey: {
              key: "conversation_style",
            },
            limit: 100,
          },
          {
            facetKey: {
              key: "message_author",
            },
            limit: 100,
          },
          {
            facetKey: {
              key: "limessagelabels",
            },
            limit: 200,
          },
        ],

```

I hope this helps resolve the issue.

Thanks,
Sai Vinay K.

View solution in original post

2 REPLIES 2

Hi @PremKolli ,

To filter the facet values dynamically based on the selected facets, the Google API returns a facet object in the response, which updates the facet values for the query. If any particular facet is selected, the facet object reflects the changes.

If you need the facet response object, you will need to send a facets payload to the API, specifying the facet names for which you want the values. With each API call, you can use the facets object to dynamically update the facet values.

Below is an example of the facet payload:

```json

facetSpecs: [
          {
            facetKey: {
              key: "conversation_style",
            },
            limit: 100,
          },
          {
            facetKey: {
              key: "message_author",
            },
            limit: 100,
          },
          {
            facetKey: {
              key: "limessagelabels",
            },
            limit: 200,
          },
        ],

```

I hope this helps resolve the issue.

Thanks,
Sai Vinay K.

Thank you Sai for the response. This helps.