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

No mechanism for injecting supplementary, dynamic filters to each query #193

Open
zopyx opened this issue Jan 23, 2024 · 5 comments
Open

Comments

@zopyx
Copy link

zopyx commented Jan 23, 2024

Feature request:

It is a common use case to add dynamic filters or subqueries in Typesense. For example, in our content management system, we want to limit the search to area=Sales when the user is in the sales folder of the portal. This filter should be applied in all cases for all facets.

Scoped API keys are not a suitable solution as the associated query is always static, and it is not feasible to have a scoped API key for every possible subquery.

The current workaround is to use toggleRefinement for the related field (area in this example) of a subquery with the setting off: Sales. This works for multiple fields, but it only works for simple field=value filters.

It would be a very useful addition if we could specify an arbitrary subquery as part of the InstantSearchAdapter configuration (for example, through additionalSearchParameters).

I understand that this feature request may fall under the scope of Algolia. Is this correct?

Complete discussion: https://typesense-community.slack.com/archives/C01P749MET0/p1705584152093769

@jasonbosco jasonbosco transferred this issue from typesense/typesense Jan 23, 2024
@jasonbosco
Copy link
Member

jasonbosco commented Jan 23, 2024

@zopyx I just remembered this feature I added a while ago. Could you try using the configure widget with filters set inside: https://github.com/typesense/typesense-instantsearch-adapter#configure

Here's a detailed thread on this topic: #17

@zopyx
Copy link
Author

zopyx commented Jan 23, 2024

@zopyx I just remembered this feature I added a while ago. Could you try using the configure widget with filters set inside: https://github.com/typesense/typesense-instantsearch-adapter#configure

Yes, but this only seems to work as long the facets remain unchanged. This is what was mentioned in the discussion on Slack. As soon facets filters are in the game, this configuration seems to be ignored.

@jasonbosco
Copy link
Member

Scratch the Configure widget suggestion. Could you try this instead of static filters: #17 (comment)

@zopyx
Copy link
Author

zopyx commented Jan 24, 2024

I tried that here:

https://gist.github.com/zopyx/9897d692571caccba60e49480fc36461#file-gistfile1-txt-L182-L184

But I don't see that this additional filter is being used.

@jasonbosco
Copy link
Member

jasonbosco commented Jan 24, 2024

That still uses the Configure widget. Could you use the helper approach like this instead: #17 (comment)

Specifically this part:

searchFunction(helper) {
        helper.addFacetRefinement('language', 'de').search();
      },

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

No branches or pull requests

2 participants