Overview
Fuse.js is a search engine built in JavaScript.
It is very useful as a search engine when creating frontend-only applications.
This time, I needed to implement exact non-match searches using Fuse.js, which required some query tricks, so this is a memo.
Advanced Search
Fuse.js supports various types of searches, including exact/partial match and partial non-match. These are described on the following page.
https://fusejs.io/examples.html#extended-search
A Japanese translation is also available in the following article.
https://qiita.com/Sashimimochi/items/4972b3dc333c6e5fb866#より高度な検索
However, for exact non-match searches, some query tricks were necessary.
Exact Non-Match Search
For example, a search for items that do not have the string “悪党” in the label field was partially achieved with the following query. It searches for “does not start with 悪党” OR “does not end with 悪党.”
Note that the above query is not perfect, as it will also exclude items with values like “悪党と悪党.”
Summary
My understanding may be incorrect in some areas, but I hope you find this helpful.