question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default Filters with Custom Widget

See original GitHub issue

Hi All,

I’m trying to get my head around using default filtering with custom widgets and I’ve come to a frustrating dead-end.

I have a car search function (make, model, price…) that I’m placing across a website and I need to search all makes and models etc which is working great, but in some places I need to default filter the search form by make e.g. Hyundai, but the rest of the makes still need to be selectable - basically a pre-selected value for an attribute - so I tried default filters (https://community.algolia.com/instantsearch.js/documentation/#default-filters).

Here’s what I’ve got so far:

var search = instantsearch({
  [...],
  urlSync: true,
  searchParameters: {
    facetsRefinements: {
      make: ['Hyundai']
    },
  }
});

With this added, I only get the value ‘Hyundai’ in the drop down along with the title ‘All makes’ BUT I don’t get any ‘hits’. The error I get in the console is “Error: make is not defined in the facets attribute of the helper configuration”. I’ve googled and have seen a few solutions but none work for me. Reading the documentation on helpers, that made me more confused as I’m unsure as to how to “connect” helpers with instsantsearch when initiating searches.

I then read about facets that aren’t defined by adding to the above:

facets: ['make']

This then pulls back all hits that are only Hyundai but leaves my select dropdown completely blank (I imagine this overrides the custom widget use). I’ve got a feeling I’m approaching this in the wrong way as I all I need to is to a pre-selected value for the attributeName ‘make’ as if someone has already selected Hyundai.

Hopefully this is not too confusing! Any pointers would be great and many thanks in advance.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
vvocommented, Sep 26, 2016

Ok I think I just fixed it by doing this:

  searchParameters: {
    hierarchicalFacetsRefinements: {
      materials: ['Glass']
    }
  }

Let me know how it goes

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change the default filter on filter widget - ServiceNow
Once you create the filter and Run, there is an option to 'Set as default filter' which you can set it. Please find...
Read more >
Can I use the default filter widget or group filte...
The group filter widget can have two different feature layers where the corresponding shared values can be filtered based on a specified value....
Read more >
Filter widget—ArcGIS Web AppBuilder | Documentation
The Filter widget allows you to limit the visibility of features in a layer. Only the features that meet the expression criteria will...
Read more >
Filters, Groups, and Tags in Primary and Custom Widgets
Many Primary Widget and Custom Widget types offer you the option to filter and/or group by multiple Harness entities and Tags. This provides...
Read more >
Create an Apply Filter Widget - Salesforce Help
Use the apply filter widget to update a page after you apply all the filters to the page, instead of updating the page...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found