mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
36 lines
796 B
TypeScript
36 lines
796 B
TypeScript
import * as lunr from 'lunr';
|
|
|
|
function basic_test() {
|
|
const index = lunr(function() {
|
|
this.field("title");
|
|
this.field("body");
|
|
this.ref("id");
|
|
this.add({
|
|
id: 1,
|
|
title: "Foo",
|
|
body: "Foo foo foo!"
|
|
});
|
|
this.add({
|
|
id: 2,
|
|
title: "Bar",
|
|
body: "Bar bar bar!"
|
|
});
|
|
});
|
|
|
|
index.search("foo");
|
|
}
|
|
|
|
function pipeline_test() {
|
|
const index = lunr(function() {
|
|
this.pipeline.add((token, tokenIndex, tokens) => {
|
|
// text processing in here
|
|
return token;
|
|
});
|
|
|
|
this.pipeline.after(lunr.stopWordFilter, (token, tokenIndex, tokens) => {
|
|
// text processing in here
|
|
return token;
|
|
});
|
|
});
|
|
}
|