This article is a mirror article of machine translation, please click here to jump to the original article.

View: 1130|Reply: 0

[Other] Fuse.js Front-end lightweight fuzzy search library (full-text search)

[Copy link]
Posted on 2025-3-3 13:25:26 | | | |
Requirements: Add full-text search functions to the front-end, such as menus, chat messages, etc. There are many full-text search middleware on the backend, such as ElasticSearch, Lucene, Solr, SQL Server built-in, etc. How to achieve full-text search on the front-end without relying on the back-end interface?

Review:

[Practical combat] Use Lucene.Net + Jieba.NET to build a lightweight in-site search
https://www.itsvse.com/thread-10690-1-1.html

Search engine selection: Elasticsearch vs Solr
https://www.itsvse.com/thread-6168-1-1.html

[Actual combat]. net/c# Call elasticsearch search via NEST [with source code]
https://www.itsvse.com/thread-6294-1-1.html

Fuse.js Powerful, lightweight fuzzy search library, written in JavaScript without any dependencies.

Official Website:The hyperlink login is visible.
Source:The hyperlink login is visible.
Parameter configuration:The hyperlink login is visible.

This article uses Angular 19 + fuse.js to implement the full-text search function, and the rendering is as follows:



npm installation


Code:


Output:

[
  {
    "item": {
      "title": "Right Ho Jeeves",
      "author": "P.D. Mans",
      "tags": ["fiction", "war"]
    },
    "refIndex": 1, // index in the original list
    "score": 0.12282280261157906
  },
  {
    "item": {
      "title": "Old Man's War fiction",
      "author": "John X",
      "tags": ["war"]
    },
    "refIndex": 0,
    "score": 0.3807307877431757
  }
]

Remark:The smaller the score is, the more accurate it is, that is, the higher the match.

Reference:The hyperlink login is visible.




Previous:The prismjs code highlighting plugin introduces the issue of all language orders
Next:The navigator.sendBeacon() method for front-end point monitoring and tracking
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com