From c68893614174c36c746222043c128d7309c816cc Mon Sep 17 00:00:00 2001 From: Kevin Schaal <76872371+m31coding@users.noreply.github.com> Date: Sat, 17 Feb 2024 19:37:05 +0100 Subject: [PATCH] fix(demo), docs: Update readme, minor demo fix, and version bump to 1.0.1 (#5) * fix(demo): fill matches table for more than 10 matches * docs: fix topN docstring * docs: add description of the query parameters * chore(package): bump version to 1.0.1 --- demo/fuzzy-demo.js | 2 +- package-lock.json | 4 ++-- package.json | 2 +- readme.md | 8 ++++++++ src/interfaces/query.ts | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/demo/fuzzy-demo.js b/demo/fuzzy-demo.js index e59c7d5..e53042a 100644 --- a/demo/fuzzy-demo.js +++ b/demo/fuzzy-demo.js @@ -509,7 +509,7 @@ function renderMatches(matches, searchDataConfig) { } function fillTableWithMatches(matches, searchDataConfig) { - for (let i = 0; i < matches.length; i++) { + for (let i = 0; i < Math.min(matches.length, 10); i++) { let row = tableBody.children[i]; row.match = matches[i]; row.children[1].textContent = searchDataConfig.getEntityString(matches[i].entity); diff --git a/package-lock.json b/package-lock.json index 91f379d..4fb0182 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@m31coding/fuzzy-search", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@m31coding/fuzzy-search", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "devDependencies": { "@faker-js/faker": "^8.3.1", diff --git a/package.json b/package.json index 8bc4fe9..c39fd97 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@m31coding/fuzzy-search", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "description": "A fast, accurate and multilingual fuzzy search library.", "homepage": "https://github.com/m31coding/fuzzy-search", diff --git a/readme.md b/readme.md index 1d9cf0d..1ab3cd0 100644 --- a/readme.md +++ b/readme.md @@ -163,6 +163,14 @@ console.dir(result2); } */ ``` +The following parameters are available when creating a query: + +| Parameter | Type | Default | Description | +| --------- | ---- | ------- | ----------- | +| string | string | - | The query string. | +| topN | number | 10 | The maximum number of matches to return. Provide Infinity to return all matches. | +| minQuality | number | 0.3 | The minimum quality of a match, ranging from 0 to 1. When set to zero, all terms that share at least one common n-gram with the query are considered a match. | + If the data terms contain characters and strings in non-latin scripts (such as Arabic, Cyrillic, Greek, Han, ... see also [ISO 15924](https://en.wikipedia.org/wiki/ISO_15924)), the default configuration must be adjusted before creating the searcher: ```js diff --git a/src/interfaces/query.ts b/src/interfaces/query.ts index 8471d52..65b798b 100644 --- a/src/interfaces/query.ts +++ b/src/interfaces/query.ts @@ -8,7 +8,7 @@ export class Query { public readonly string: string; /** - * The maximum number of matches to return. If undefined, all matches will be returned. + * The maximum number of matches to return. Provide Infinity to return all matches. */ public readonly topN: number;