Skip to content

Commit

Permalink
feat(full-text-search): implement extended fuzzy (#47)
Browse files Browse the repository at this point in the history
* refactor classes FuzzySearch and WildcardSearch to functions
  • Loading branch information
Viatorus authored Nov 23, 2017
1 parent 33e1ce7 commit 0579026
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 181 deletions.
17 changes: 17 additions & 0 deletions packages/full-text-search/spec/generic/search/fuzzy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,21 @@ describe("fuzzy query", () => {
let query = new QB().fuzzy("body", "weber").prefixLength(1).fuzziness(2).build();
assertMatches(fts, query, [6, 8, 9, 10, 11, 12, 13, 14]);
});

it("Fuzzy query extended.", () => {
let docs = ["walker", "wbr", "we", "web", "webe", "weber", "webere", "webree", "weberei", "wbes", "wbert", "wbb",
"xeb", "wrr"];
let fts = new FullTextSearch([{name: "body"}]);
for (let i = 0; i < docs.length; i++) {
fts.addDocument({
$loki: i,
body: docs[i]
});
}
let query = new QB().fuzzy("body", "web").prefixLength(1).fuzziness(1).extended(true).build();
assertMatches(fts, query, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);

query = new QB().match("body", "web").prefixLength(1).fuzziness(1).extended(true).build();
assertMatches(fts, query, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
});
});
Loading

0 comments on commit 0579026

Please sign in to comment.