Unable to retrieve more than one attributes in the result hits

I’m using Instasearch and my search result includes only one attribute which is the hierarchy.lvl1. I have the following template:

templates: {
    item: `
        <div>
          <div class="hit-name">
              {{#helpers.highlight}}{ "attribute": "hierarchy.lvl1" }{{/helpers.highlight}}
          </div>
          <div class="hit-description">
              {{#helpers.highlight}}{ "attribute": "hierarchy.lvl2" }{{/helpers.highlight}}
          </div>
    </div>`,
},

As you can see, I’m trying to display the hierarchy.lvl2 attribute as the description but it returns nothing. I’ve console logged the return items using transformItems, I can see all the hierarchical attributes are returned properly but not available when I try to use them in the template.

transformItems: function (items) {
      console.log(items)
},

In addition, I’ve also added hierarchy.lvl2 attribute under Attributes for faceting and Attributes to retrieve in the Algolia dashboard.

I’m I missing anything here? Please help me fix this.

Hi @rushenn – In order to show up among the highlighted attributes in your hits, an attribute must be a searchable attribute . For non-searchable attributes where you don’t care about highlighting, you can just reference it as a standard attribute of your hit:

          <div class="hit-description">
              {hit.hierarchy.lvl2}
          </div>
1 Like

@chuck.meyer Thank you very much for your quick response. Adding the attributes to the Attributes to highlight worked for me.

1 Like