当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lunr类代码示例

本文整理汇总了TypeScript中lunr的典型用法代码示例。如果您正苦于以下问题:TypeScript lunr类的具体用法?TypeScript lunr怎么用?TypeScript lunr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了lunr类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: basic_test

function basic_test() {
    const index = lunr(function() {
        this.field("title");
        this.field("body");
        this.field("content", {
            boost: 2,
            extractor: (doc: object) => "oof"
        });
        this.ref("id");
        this.add({
            id: 1,
            title: "Foo",
            body: "Foo foo foo!"
        },
        {
            boost: 2
        });
        this.add({
            id: 2,
            title: "Bar",
            body: "Bar bar bar!"
        });
    });

    index.search("foo");
}
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:26,代码来源:lunr-tests.ts

示例2: pipeline_test

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;
        });
    });
}
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:13,代码来源:lunr-tests.ts

示例3: createIndex

// Create the lunr index - the docs should be an array of objects, each object containing
// the path and search terms for a page
function createIndex(loadIndex: IndexLoader): lunr.Index {
  // The lunr typings are missing QueryLexer so we have to add them here manually.
  const queryLexer = (lunr as any as { QueryLexer: { termSeparator: RegExp } }).QueryLexer;
  queryLexer.termSeparator = lunr.tokenizer.separator = /\s+/;
  return lunr(/** @this */function () {
    this.ref('path');
    this.field('titleWords', { boost: 10 });
    this.field('headingWords', { boost: 5 });
    this.field('members', { boost: 4 });
    this.field('keywords', { boost: 2 });
    loadIndex(this);
  });
}
开发者ID:alxhub,项目名称:angular,代码行数:15,代码来源:search-worker.ts

示例4: basic_test

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");
}
开发者ID:DenisCarriere,项目名称:DefinitelyTyped,代码行数:19,代码来源:lunr-tests.ts

示例5: basic_test

function basic_test() {
    const index = lunr(function() {
        this.field("title");
        this.field("body");
        this.field("content", {
            boost: 2,
            extractor: (doc: object) => "oof"
        });
        this.ref("id");
        this.add({
            id: 1,
            title: "Foo",
            body: "Foo foo foo!"
        },
        {
            boost: 2
        });
        this.add({
            id: 2,
            title: "Bar",
            body: "Bar bar bar!"
        });
    });

    index.search("foo");

    index.query(q => {
        q.term(
            lunr.tokenizer('search terms'),
            {
                wildcard: lunr.Query.wildcard.TRAILING,
                presence: lunr.Query.presence.REQUIRED
            }
        );
    });
}
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:36,代码来源:lunr-tests.ts


注:本文中的lunr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。