How to retain(OR) options in a faceted search

I have added a metafield named ‘forwhom’ in Shopify and added to facets as hidden via Algolia search configuration.

I added the below code in algolia_instant_search.js.liquid

if(getParameterByName(‘cat’) == “mycategory” ){

//custom_begins
var cssClasses = JSON.parse(JSON.stringify(algolia.facetCssClasses)); // Clone the classes object
// You can modify cssClasses if you want here

instant.search.addWidget(
      instantsearch.widgets.refinementList({
        container: '[class~="ais-facet-meta.global.forwhom"]',
        attributeName: 'meta.global.forwhom',
        operator: 'or',
        limit: 5,
        cssClasses: cssClasses,
        collapsible:false,
        templates: {
          header: function () { return 'For Whom (Added via code)'; },
        }
      })

);

}

I am able to select only one option(there are two options - male and female) - if I set type as ‘disjunctive’ in Algolia facet configuration it works fine, but I can set it as hidden only because I dont want to show with some other categories.

Feel free to ask if you need more info on this.

This should work fine. The operator: 'or' should automatically set it as disjunctive, and you should be able to select both.
Do you have a preview link of your theme so that I could check it out?

//qvurst-123.myshopify.com/search?cat=gold

Enabled the read access, let me know if you need more info.

I will actually need the store’s front password (not admin, the one on the homepage because the store isn’t opened yet).
If you don’t want to share it here, you can send it to us via email to support+shopify@algolia.com . :slight_smile:

reabru

More details sent to email.

I might have misunderstood what you were trying to achieve.
It currently works as I thought you wanted it to work.
When you select “Men”, you can still select Woman, and vice-versa, and you can select both.

Did you have to make any modification? Or did I just misunderstand your question?

Yes - Since algolia shopify was down for hours we continued with other work, no problem we managed to handle it with javascript.

Now we have another blocker that we cannot use text metafields in algolia ionRangeSlider.

Is there any workaround for that?

Shopify cannot create float type metafields and algolia cant perform ionRangeSlider for text strings, really blocked with issue - we need to add float values in shopify metafields and slide it using algolia ionRangeSlider.

In which plugin file(Shopify alogilia ) the metafields are indexed to algolia, can we change the data type to float there?

Please help.

Unfortunately, there’s no way to plug yourself to transform the metafields we index. This would require a full framework allowing code execution, which would be too complex to implement.

I see two solutions here:

  • You could simply change your metafield to integer (or index a new one) by multiplying it and dividing it in the front-end
  • You could use named tags instead, which support floats

Thanks Jerska

We started using named tags and it works like charm.

It will be great if you guys show an example in documentation how to create a named tag(Shopify perspective) - initially we felt bit confused.

Thanks for the support again

Great news!

You’re right, I should probably add a small screenshot showing how to do it!
Thanks for the suggestion. :slight_smile:

Much appreciated!

We added a named tag Crt for products(Excel sheet screenshot) and it is listed in inactive section of algolia faceted configuration.
We moved it to the Active session and it worked as expected.

But after a few minutes the same Crt named tag began to appear also in Inactive section. Is this expected or anything wrong from our side?

Crt-tag

This is indeed unexpected, but it might just be a display issue on our side.
Just in case, could you click on Edit (hover on top of it) for both and send a screenshot of both?

Active

Inactive

Also, is it correctly displaying in your front-end? :slight_smile:

Yes working correctly(as slider) in frontend :slight_smile:

Feel free to ask if you need more input on this to fix the issue.

Alright great!
This is probably a display issue on my side.

If it displays fine in your front-end, you can ignore the Inactive one. :slight_smile:
Thanks for reporting that!

I’ve just found the issue. I confirm it was only visual.
If you reload the page you should now correctly see it only once, in Active.

Wow, Much appreciated!

Excellent Support.

1 Like

When you’ve finished setting up Algolia, we’d love if you could give us a rating on https://apps.shopify.com/algolia-search .
We’re still pretty low in terms of reviews, and are trying to get more visibility.
This would mean a ton to us! :slight_smile: