Instantsearch.js: Cannot fetch value from the attributeName which is in hierarchical level

Created on 28 Feb 2018  路  17Comments  路  Source: algolia/instantsearch.js

I am having a hierarchical object in json. I am using connectMenu to list out the catogories in a dropdown. When I give attributeName: "taxonomies_hierarchical.category.lvl0" i got response. But When I give attributeName: "taxonomies_hierarchical.category.lvl1", the result is empty. How can I get the lvl1 values?

"taxonomies_hierarchical": {
        "category": {
          "lvl0": [
            "Manchester"
          ],
          "lvl1": [
            "Manchester > Hopwood House"
          ]
        }
}
Needs Investigation

Most helpful comment

Hi @bobylito thanks for your reply. Here is the link for live reproducible, https://codesandbox.io/s/yp07y8vp6z. when I use the menu widget with attributeName : "taxonomies_hierarchical.locations.lvl0". I can get the values. But when I give attributeName : "taxonomies_hierarchical.locations.lvl1" am getting empty response. At the same time am getting value in refinementList

All 17 comments

Hi @AmshaRanjani thanks for opening this issue. Would it be possible to get a live reproducible test case of your problem? It would help us a lot. You can do so using the codesandbox template here.

Hi @bobylito thanks for your reply. Here is the link for live reproducible, https://codesandbox.io/s/yp07y8vp6z. when I use the menu widget with attributeName : "taxonomies_hierarchical.locations.lvl0". I can get the values. But when I give attributeName : "taxonomies_hierarchical.locations.lvl1" am getting empty response. At the same time am getting value in refinementList

Any updates on this?
I'm also facing same issue with my categories. I need to display level 2 categories in a filter as showing level 0 categories doesnt make sense when user is on level 1 page.

i have uploaded file in algolia dashboard n get the appid, apikey,indexname while im puting that in search.js n i wrote the code for category as

search.addWidget(
  instantsearch.widgets.hierarchicalMenu({
      container: '#hierarchical-categories',
      attributes: [
        'hierarchicalCategories.lvl0',
        'hierarchicalCategories.lvl1',
        'hierarchicalCategories.lvl2',
      ],
      showParentLevel: true,
      templates: {
          header: getHeader('Category'),
          item:  '<a href="{{url}}" class="facet-item {{#isRefined}}active{{/isRefined}}"><span class="facet-name"><i class="fa fa-angle-right"></i> {{label}}</span class="facet-name"><span class="ais-hierarchical-menu--count">{{count}}</span></a>' // eslint-disable-line
      },
  })
);

but i didnt get category widget

Are your attributes set up as attributesForFaceting @patilvarsh ?

yes

Can you make an example on CodeSandbox please, there's a template here

Ok

we are getting following error,
Unhandled Rejection (AlgoliaSearchJSONPScriptErrorError)

Can you send an email to [email protected] @patilvarsh?

hello anyone have solution for this

could you send an email to support please @patilvarsh, the bug tracker is for bugs, not for support. One thing that could be going wrong is the fact that you might not have not set it up as attributes for faceting.

The hierarchical menu widget is used to create a navigation based on a hierarchy of facet attributes.

It is commonly used for categories with subcategories.

All attributes (lvl0, lvl1 here) must be declared as attributes for faceting in your Algolia settings.

By default, the separator we expect is > (with spaces) but you can use a different one by using the separator option.

yup i set all this there are 3 levels category 1, category 2,category 3 when click on category 1 it splits after that i click on category 2 it should be show the category 3 product in hit area but it shows we didnt find any result for search.

I can't help based on screenshots, can you please send an email to [email protected] with the code relevant?

yes i sent mail to [email protected]

Closing because handled on support.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bobylito picture bobylito  路  3Comments

francoischalifour picture francoischalifour  路  3Comments

devwax picture devwax  路  3Comments

nicosrugeris picture nicosrugeris  路  3Comments

Spone picture Spone  路  3Comments