Index
是一个平面的高性能索引,用于存储 id-content-pairs。Worker
/ WorkerIndex
也是一个平面索引,它存储 id-content-pairs,但作为专用工作线程在后台运行。Document
是多字段索引,可以存储复杂的 JSON 文档(也可能存在工作器索引)。
根据你的方案,你们中的大多数人可能只需要其中之一。import Index from "./index.js";
import Document from "./document.js";
import WorkerIndex from "./worker/index.js";
const index = new Index(options);
const document = new Document(options);
const worker = new WorkerIndex(options);
<html>
<head>
<script src="js/flexsearch.bundle.js"></script>
</head>
或者 CDN
<script src="https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.7.31/dist/flexsearch.bundle.js"></script>
npm install flexsearch
使用:
const { Index, Document, Worker } = require("flexsearch");
const index = new Index(options);
const document = new Document(options);
const worker = new Worker(options);
index.add(id, text);
index.search(text);
index.search(text, limit);
index.search(text, options);
index.search(text, limit, options);
index.search(options);
document.add(doc);
document.add(id, doc);
document.search(text);
document.search(text, limit);
document.search(text, options);
document.search(text, limit, options);
document.search(options);
worker.add(id, text);
worker.search(text);
worker.search(text, limit);
worker.search(text, options);
worker.search(text, limit, options);
worker.search(text, limit, options, callback);
worker.search(options);