This package provides simplified searching through text content of documents.
import {ReferenceIndex} from "jsr:@nodef/extra-text-search";
const index = new ReferenceIndex();
// Add some text to the index
index.add("doc1", "Humpty Dumpty sat on a wall.");
index.add("doc2", "Humpty Dumpty had a great fall!");
index.add("doc3", "Like a sunflower that follows every movement of the sun.");
index.add("doc4", "The sun is a mass of incandescent gas, a gigantic nuclear furnace.");
// Search for flowers
index.search("flowers");
// → Map(2) { "doc3" => 0.08733909728084097 }
// Search for umpty fall great
index.search("umpty fall great");
// → Map(2) { "doc2" => 0.45927932677184585, "doc3" => 1.6738179909018382 }
This project is licensed under AGPL-3.0.