How to return more than value and counter on Facet Values?

By default, a facet will return the possible value (in the language of the request) as well as its counter (the number of products matching this value.

This information si part of the “bx-facets” of the Boxalino Narrative API response, you can find more information here.

In this article, we describe how you can add more information to be returned in the facet response (like url-slug, id, key, images, etc.).

Provide more information about each value

In doc_attribute_value data

The most efficient and dynamic way to provide more information is to do it as part of the data you are exporting to Boxalino.

More precisely, we speak here about the doc_attribute_value data (find the documentation here).

The following additional parameters will be generated and can be returned as additional data with each of your facet values:

bx-facet-value-parameter

source in doc_attribute_value

comment

bx-facet-value-parameter

source in doc_attribute_value

comment

id

value_id

 

image_names

images[*].name

only interesting to see if several different image names are defined

image_value_ids

images[*].values[*].value_id

retrieve the list of non-localized image value ids set

image_values

images[*].values[*].value[language=REQUEST_LANGUAGE]

retrieve the localized image values (in current language), most often what you need

link

link[language=REQUEST_LANGUAGE]

link of the value label (useful for brand and categories in particular if they have a dedicated landing page url)

key

string_attributes[name='key'][0]

the string value of the parameter ‘key’ if any is provided

swatch

string_attributes[name='swatch'][0]

typically a path to a picture or an icon for swatch facets (like the color), find more info here

target_language

REQUEST_LANGUAGE

can be ignored, simply matches the request language

By configuring a “facetValueExtraInfo” advanced parameter in the admin

Another way to configure additional information to be returned for each facet value is to define them in the admin configuration of the Facet.

This must be done in an advanced parameter called “facetValueExtraInfo” and must have the following JSON format:

This means the value of the field (which, if the field values are localized, mean you need to define the value for each possible localized value) and, for each, a list of properties, with the following logics:

  • localized parameter
    As in the example above for “label”, you want to define a value which is different in each language, then you need to define the value with a JSON object structure as {“de”:”value in de”, “fr”:”value in fr”, …}
    This will automatically return the value in the currently requested language in the response as here:

    Any other parameter with either only a string, a number or a different JSON object structure will be return as provided.

  • order
    if you provide an order parameter (as in the example above) the values will be ordered according to the numeric value of the order provided.
    Make sure you do not set any value ordering in the facet options, otherwise the provided order values will not be used to order the facet values.

Request this extra facet value data be returned

If you define the facetValueExtraInfo in the admin, you do not need to do anything for them to be returned, but if you provide them in the doc_attribute_value you should define the following either in the Facet configuration or in your API request:

In the API request (in the “facets” parameters) “"rtux-data-integration_facetValueExtraInfo" in extraInfo->facet-value-correlation

{ "field": "manufacturer", "maxCount": -1, "minPopulation": 1, "sort": "1", "sortAscending": false, "andSelectedValues": false, "extraInfo": { "facet-value-correlation": "rtux-data-integration_facetValueExtraInfo" } }

In the admin: “rtux-data-integration_facetValueExtraInfo” in Parameters: “facet-value-correlation”:

If you provide the data in doc_attribute_value the information will not be immediately available after a full product data sync. The Daily Synchronization needs to be run as well for these data to be returned (please contact Boxalino for more information if you have defined your doc_attribute_value data and are requesting the "rtux-data-integration_facetValueExtraInfo" in your request but do not receive the added information in your facet response.