#community-help

Implementation and Testing of Negative Filtering on Typesense

TLDR Stefan needed an ETA on implementing negative filtering on layer of typesense. Kishore Nallan provided updates, fixes, and an early build for testing. Further plans on adding it to instantsearch adapter were discussed, with Stefan also offering to contribute.

Powered by Struct AI

2

1

23
31mo
Solved
Join the chat
Apr 27, 2021 (31 months ago)
Stefan
Photo of md5-d6c265b4792dbf0a1d6ae378f39d8736
Stefan
06:33 AM
Hi, is there an ETA on "negative faceting" e.g. "-Apples"? That is kind of the last roadblock for me to get rid of my crazy algolia bill
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
06:36 AM
๐Ÿ‘‹ I can assess the changes needed and give you an update later.

In the mean time, the issues you identified with highlighting and typo correction should be fixed in 0.20.0.rc49 docker image. It will be great if you can give it a spin and let me know if it works!
Stefan
Photo of md5-d6c265b4792dbf0a1d6ae378f39d8736
Stefan
06:43 AM
Awesome thank you!
And I just upgraded and it seems to be fixed! Thank you

Only minor thing: I assume typesense doesn't ignore dashes?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
06:43 AM
A word like catch-up will be indexed as catchup.
06:44
Kishore Nallan
06:44 AM
If you want it to be indexed as a two separate words, you have to split it up before indexing.
Stefan
Photo of md5-d6c265b4792dbf0a1d6ae378f39d8736
Stefan
06:44 AM
okay that is doable
May 03, 2021 (31 months ago)
Stefan
Photo of md5-d6c265b4792dbf0a1d6ae378f39d8736
Stefan
08:07 AM
Kishore Nallan you got a chance to estimate the workload for negative filtering?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
08:26 AM
End of the week, if I don't run into any blockers during implementation.

1

Stefan
Photo of md5-d6c265b4792dbf0a1d6ae378f39d8736
Stefan
08:56 AM
Awesome thank you
May 06, 2021 (31 months ago)
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
04:09 AM
Stefan Just to be clear: when you say negative faceting, you mean negative filtering right? So, something likeย color:- blueย would match records which are not blue.
Stefan
Photo of md5-d6c265b4792dbf0a1d6ae378f39d8736
Stefan
04:10 AM
Yes exactly
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
04:24 AM
Cool. I've started working on it.

1

Stefan
Photo of md5-d6c265b4792dbf0a1d6ae378f39d8736
Stefan
05:32 AM
Awesome! Happy to alpha test at anytime!
May 07, 2021 (31 months ago)
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
08:19 AM
Stefan I've got an early build for you to test: typesense/typesense:0.21.0.rc2

Currently supporting the exclusion operator (-) on only string facets. Usage:

filter_by=author:- JK Rowling (excludes a single value)

filter_by=author:- [JK Rowling, Enid Blyton]
(excludes both authors)

If you want to include some and exclude others you can have two filter_by clauses separated by && e.g.

filter_by=author:- [JK Rowling, Enid Blyton] && author: [JRR Tolkien, John Grisham, George Martin]
08:21
Kishore Nallan
08:21 AM
Though the last example doesn't make any sense for the same field. But just to give a gist.
May 10, 2021 (31 months ago)
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
06:18 AM
Please use typesense/typesense:0.21.0.rc4 -- this also has a fix for the other bug you identified Stefan -- the issue of escaping commas in filter value list during filtering. You can now wrap strings in backtick () to achieve that. E.g. ```place: [London, UK, Paris, France`] ```
Stefan
Photo of md5-d6c265b4792dbf0a1d6ae378f39d8736
Stefan
06:21 AM
Awesome, thank you! Already playing with it ๐Ÿ™‚
May 11, 2021 (31 months ago)
Stefan
Photo of md5-d6c265b4792dbf0a1d6ae378f39d8736
Stefan
02:21 PM
it seems to be working pretty flawless so far. I already took a stab at adding it to the instantsearch adapter Jason do you have something planned there as well?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
02:31 PM
Stefan I havenโ€™t added it to the adapter yet. If youโ€™ve already done it, a PR would be awesome!
Stefan
Photo of md5-d6c265b4792dbf0a1d6ae378f39d8736
Stefan
02:32 PM
I started working on it, works, but is a bit buggy. I will create a draft PR so we can discuss what would be the best approach.

1

Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
02:33 PM
Stefan
Photo of md5-d6c265b4792dbf0a1d6ae378f39d8736
Stefan
02:34 PM
sure will do! Probably won't get it to it today, but tomorrow for sure
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:56 PM
One current limitation is that it only works for string facets. Just something to be aware of during implementation, and we will eventually add support for other types.