lunrjs - A bit like Solr, but much smaller and not as bright.

lunrjs

https://github.com/olivernn/lunr.js

Lunr.js is a small, full-text search library for use in the browser. It indexes JSON documents and provides a simple search interface for retrieving documents that best match text queries.

      Small full-text search engine for browser-side design (Nonetheless, it is still supported nodejs platform running https://lunrjs.com/).

      When the index object JSON document that provides a simple interface to search, get the best match text search.

     This feature is similar to mongo and elastic server-side full-text search capabilities.

 

WHY

For web applications with all their data already sitting in the client, it makes sense to be able to search that data on the client too. It saves adding extra, compacted services on the server. A local search index will be quicker, there is no network overhead, and will remain available and useable even without a network connection.

       Advantage:

       1) The client get the data, by the client should have a single search.

       2) reduce the pressure on the server side.

       3) reduce the pressure on the network.

       4) net off the case can still be used. In favor of web application type (PWA applet).

 

Features

  • Full text search support for 14 languages
  • Boost terms at query time or boost entire documents at index time
  • Scope searches to specific fields
  • Fuzzy term matching with wildcards or edit distance

1) support in 14 languages, unfortunately, does not support Chinese. https://lunrjs.com/guides/language_support.html

   But the Chinese have a big brother to achieve support: https://github.com/olivernn/lunr.js/issues/91

2) support a number of query terms, support for the entire document indexing.

3) defining a search field.

4) fuzzy matching.

 

EXAMPLE

https://lunrjs.com/docs/index.html

A very simple search index can be created using the following:

var idx = lunr(function () { this.field('title') this.field('body') this.add({ "title": "Twelfth-Night", "body": "If music be the food of love, play on: Give me excess of it…", "author": "William Shakespeare", "id": "1" }) })

Then searching is as simple:

idx.search("love")

This returns a list of matching documents with a score of how closely they match the search query as well as any associated metadata about the match:

[
  {
    "ref": "1", "score": 0.3535533905932737, "matchData": { "metadata": { "love": { "body": {} } } } } ]

API documentation is available, as well as a full working example.

 

Online Demo

address

https://olivernn.github.io/moonwalkers/

Source Address

https://github.com/olivernn/moonwalkers

 

Function Description:

All managed and celebrities introduce index, at the time the search page to find the target document in the index, and use the keyword search of documents marked yellow mark display.

 

Project

1) Index (docs / index.json) construct, generated in the project compile time. build-index script generation.

2) Web page to run, load index (docs / index.json), generate a search engine,

3) User index when using a search engine, into the relevant documents, and more ref index number to find the document and display.

 

Guess you like

Origin www.cnblogs.com/lightsong/p/12241812.html
Bit
BIT