Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with filter_by parameters when using facets #196

Closed
alexgvozden opened this issue Feb 22, 2024 · 5 comments · May be fixed by #197
Closed

Issue with filter_by parameters when using facets #196

alexgvozden opened this issue Feb 22, 2024 · 5 comments · May be fixed by #197

Comments

@alexgvozden
Copy link

Description

If you set filterBy in the search configuration and use facet filtering with RefinementList, the facet filter overwrites (ignores) filterBy configuration which results in more results

Steps to reproduce

For example if I filter all results by default from config with filterBy
additionalSearchParameters: {
queryBy: "embeddings,title",
vectorQuery: embeddings:([], distance_threshold:0.1),
perPage: 10,
filterBy: "score:>6",
},

and than use facets with

Than request made to server will contain filterBy score, but if I click one of the refinement options facets, than filterBy score is ignore and overwritten by facet filterBy option.

Expected Behavior

Filtering by facet should not ignore and overwrite configured filterBy parameter.

Actual Behavior

Filtering by facet overwrites filter_by parameter in request and only uses facets filter

Metadata

Typesense 0.25.2

Mac OSX

alexgvozden pushed a commit to alexgvozden/typesense-instantsearch-adapter that referenced this issue Feb 22, 2024
alexgvozden pushed a commit to alexgvozden/typesense-instantsearch-adapter that referenced this issue Feb 22, 2024
@alexgvozden alexgvozden mentioned this issue Feb 22, 2024
1 task
@alexgvozden
Copy link
Author

alexgvozden commented Feb 22, 2024

I have fixed this issue and prepare pull request. Please test and merge if that is ok so in next release it's included.
If you foresee some issues, lets say of duplicate keys, than it can be fixed, but overall it would continue to work as it was, as I have included filterBy parameter to be added first.
Thank you

@jasonbosco
Copy link
Member

Thank you for the PR, it's an interesting way to solve this.

But, there is actually already a way to setup fixed filter from within Instantsearch: #17 (comment)

@alexgvozden
Copy link
Author

alexgvozden commented Feb 23, 2024

Hi, thank you for your answer

If I understand correctly than filter_by is meant to be removed even if it's specified in initial search paramters?

example you provided is about adding a facet helpr, while I have an issue with filter_by property being removed (not for facet but score, which is just a field)

I will try to find if using searchFunction can help for that and what are the function but I see searchFunction is depreceted and onStateChange should be used.

if you can help me understand how to retaing filter_by without changing the code of the library it woudl be great

@jasonbosco
Copy link
Member

If I understand correctly than filter_by is meant to be removed even if it's specified in initial search paramters?

That's correct. This is how the InstantSearch library works when used without Typesense. You'd typically use the configure widget to setup default search parameters, and then the other filter widgets will override the default parameters.

example you provided is about adding a facet helpr, while I have an issue with filter_by property being removed (not for facet but score, which is just a field)

It's a facet refinement, which is how Instantsearch calls filtering.

searchFunction is depreceted and onStateChange should be used

I'm not familiar with this deprecation, but if you look at Instantsearch / Algolia forums on how to setup a fixed a fixed filter, you should find the latest way to do this from within Instantsearch.

@alexgvozden
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants