You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd really appreicate any input on this! I am trying to create my own custom range connector that takes in 2 attributes (a minAttribute and a maxAttribute) instead of 1. The way it works is that when a user enters a user_min value, the custom range connector will refine to show objects with a maxAttribute > user_min and when a user enters a user_max, the custom range connector will refine to show objects with a minAttribute < user_max. If the user enters both a user_min and user_max then it just finds the intersection of the previous scenarios.
Issue
My current range connector works for the most part, but the issue arrises for the following scenarios:
if the user enters only a user_min (undefined user_max) and the user_min is greater than all the maxAttribute values, instead of showing 0 results, it does not even try to refine the search. This is fine I guess since I can put a min and max attribute on the form <input> element, but the "range" parameter returned from my custom useRange hook keeps returning {min: 0, max: 0}
Example
I have 3 objects in my index -> {minPrice: 10, maxPrice: 20}, {minPrice: 30, maxPrice: 40}, {minPrice: 50, maxPrice: 60}
Now if the user inputs a min value of 100 with no max_value, instead of showing 0 results, it still shows 3. Similarly, if the user inputs a max value of 5 with no min_value, instead of showing 0 results, it still shows 3. The weird thing is that if the user inputs a min value of 100 and a max value of 101 (instead of undefined) then it will return 0 results.
I tried using "range" from const { start, range, canRefine, precision, refine } = useCustomRange(props); to set min and max limits on my form <input/> element but like I said, it gives me {min: 0, max: 0}.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Use Case
I'd really appreicate any input on this! I am trying to create my own custom range connector that takes in 2 attributes (a minAttribute and a maxAttribute) instead of 1. The way it works is that when a user enters a user_min value, the custom range connector will refine to show objects with a maxAttribute > user_min and when a user enters a user_max, the custom range connector will refine to show objects with a minAttribute < user_max. If the user enters both a user_min and user_max then it just finds the intersection of the previous scenarios.
Issue
My current range connector works for the most part, but the issue arrises for the following scenarios:
Example
I have 3 objects in my index -> {minPrice: 10, maxPrice: 20}, {minPrice: 30, maxPrice: 40}, {minPrice: 50, maxPrice: 60}
Now if the user inputs a min value of 100 with no max_value, instead of showing 0 results, it still shows 3. Similarly, if the user inputs a max value of 5 with no min_value, instead of showing 0 results, it still shows 3. The weird thing is that if the user inputs a min value of 100 and a max value of 101 (instead of undefined) then it will return 0 results.
I tried using "range" from
const { start, range, canRefine, precision, refine } = useCustomRange(props);
to set min and max limits on my form <input/> element but like I said, it gives me {min: 0, max: 0}.Supplementary Information
Here is my custom range connector if you feel like you need extra details. I essentially copied the default range connector (https://github.com/algolia/instantsearch/blob/master/packages/instantsearch.js/src/connectors/range/connectRange.ts), but tweaked the lines that had "attribute" to use minAttribute and maxAttribute instead.
Beta Was this translation helpful? Give feedback.
All reactions