Label for facet values

How to show label instead of values in facets.

For example: Consider following facets
country_data: [ { title: "Wrangell–St1", country : "US" }, { title: "Wrangell–St2", country : "IN" } ]

Where i have to show countries in facet based on custom display names at client side rendering.

map displayNames / label's from : countyNames: {"US" : "United States", "IN" : "India" } which is getting from backend.

     - United States (1)
     - India (2)

Is there anything like label or title that I can use to show this?

Thanks in advance!

Hi @Swapnil_Ghorpade, this is something you'll need to code yourself on the front end. There's no way to provide labels for facet values automatically.

Your other option would be to do it at Index time. You could index two fields ... country and country_display.

@JasonStoltz Thanks for the response.

Yes, I tried other thing which gives me expected output.
I can able to show any custom string as label to facet value.

please correct me if I am doing anything wrong

here is the Code:

const apiConnector = new AppSearchAPIConnector({
 searchKey: searchKey,
 engineName: engineName,
 hostIdentifier: hostIdentifier,
 beforeSearchCall: async (existingSearchOptions, next) => {
   const existingFilters = existingSearchOptions.filters || { none: [] };

   const existingFiltersAll = existingFilters.all ? existingFilters.all : []; => {
         const existingFiltersAny = allFilter.any;
         return => {
         const obj = filter;

        // Replace type value label with actual index id to search
        if (filter.type) {
           obj.type = getIdByLabel(filter.type);

        return obj;

   const results = await next({

  // Replace Types id with display name in facets
  results.facets.type[0].data = results.facets.type[0] => {
    const obj = result;
    obj.value = getLabelById(result.value);
    return obj;

    return results;
1 Like