feat(typesense): add whereNotIn
filter to typesense engine
#878
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
Currently, the Typesense driver doesn't process
whereNotIn
constraints in search queries, which limits the ability to exclude specific records from search results.For example, when searching for products and wanting to exclude specific categories:
This enhancement implements the missing
whereNotIn
functionality, allowing users to properly filter out unwanted results from their Typesense searches, making the search experience more flexible and precise.Changes
Added Features:
src/Engines/TypesenseEngine.php
:parseWhereNotInFilter()
: Handles the conversion of whereNotIn constraints toTypesense filter syntax using
!=[...]
notation.Code Changes:
src/Engines/TypesenseEngine.php
:filters()
method to processwhereNotIn
constraints alongsideexisting
where
andwhereIn
filtersmethods
&&
operator placementTest Updates:
tests/Unit/TypesenseEngineTest.php
:test_parse_where_not_in_filter_metheod()
to verifywhereNotIn filter generation
test_filters_method()
to include whereNotIn scenariosContext
This PR addresses issue #876 reported by @alexfierro where
whereNotIn
constraints werenot being handled by the Typesense driver. The implementation follows the suggested
approach of adapting the existing
whereIn
logic with the appropriate Typesensefilter syntax for exclusions.
Before:
After: