How to stop AlgoliaSearchHelper .search() from revoking my numericRefinements #6052
Unanswered
AbdelrahmanAhmed605
asked this question in
Q&A
Replies: 2 comments
-
I tried putting a |
Beta Was this translation helpful? Give feedback.
0 replies
-
Could you post all the code? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd really appreicate any input on how to fix the issue presented below! I already found the cause of the issue but I am not too sure how to fix it.
Use Case
I created my own custom range connector that takes in 2 attributes (a minAttribute and a maxAttribute) instead of 1. The way it works is as follows:
Issue
Currently when a user inputs a number outside the bounds, the search is not refining to show "0 results" and instead just shows all the data in my index.
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 max value of 5, instead of showing "0 results", it shows all the data in my index ("3 results" in this case)
Cause of Issue
Note: I am using this file but with my own custom logic (https://github.com/algolia/instantsearch/blob/master/packages/instantsearch.js/src/connectors/range/connectRange.ts)
After looking at the connectRange function, I see that the issue stems in the
_refine
functionWhen I do
The logs of the refinedState correctly shows the applied numericRefinement
but then in the next step in the
_refine
function, it sets a new state for the helper instance and then does a .search()After applying the search for the new state, when I console log the helper instance and I look at the state object, the numericRefinement in the refinedState was removed.
As you can see the helper instance removed the minimumPrice refinement from its state on its own. Why does the .search() function remove my refinement?
Beta Was this translation helpful? Give feedback.
All reactions