Add support for queryRuleContext
widget
#223
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rationale
Introduce the
queryRuleContext
widget to enhance the search experience by allowing dynamic application of rules based on the current search context. This feature will enable more targeted and relevant search results by transforming rule contexts into override tags. By doing so, we're bridging the gap between Algolia's query rules and Typesense's overrides, making it easier for developers to migrate their applications while maintaining advanced search functionalities.Changes
Added Features:
src/SearchRequestAdapter.js
:Code Changes:
src/SearchRequestAdapter.js
:adapt
method to include logic for transformingruleContexts
to override tags.Test Updates:
In
test/queryRuleContext.test.js
:In
test/support/populateProductsIndex.js
:In
test/widgets.test.js
:queryRuleContext
widget.Documentation Updates:
README.md
or relevant documentation file:queryRuleContext
.Demo
In this example, when a user searches for products and the brand filter includes 'Apple' or 'Samsung', the corresponding context rule will be applied. This context is then transformed into an override tag in the Typesense query, allowing for more specific and relevant search results based on the current context. This way, the overrides aren't automatically applied, but specifically triggered only when the tracked filters are applied
PR Checklist