4

SharePoint Online 调用PnP.js 搜索返回结果不完整

 2 years ago
source link: https://www.cnblogs.com/jianyus/p/15750630.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

SharePoint Online 调用PnP.js 搜索返回结果不完整

  前言

  最近,有使用PnP里面的Search方法,然后发现,返回的结果里面总是缺少一部分,查了好久才发现问题。

  正文

  我们直接上代码,这个其实也不是bug,就是SharePoint搜索本身的一个特性,默认会在搜索结果中,去掉疑似重复的返回结果!

  注意,是疑似重复的返回结果,至于如何定义的重复,我们也无从知道。我们能做的就是,通过一个叫做TrimDuplicates的参数,让SharePoint默认不去重!

    sp.search(<any>{
        TrimDuplicates: false,
        Querytext: queryText,
        RowLimit: rowLimit,
        SourceId: sourceId,
        RefinementFilters: refinementFilters,
        SelectProperties: selectProps
    }).then(req => {
        resolve(req);
    }).catch(err => {
        reject(err);
    });

  结束语

  怎么说呢?一个很恶心的设置,很多时候,即使做了多年开发,也很容易忽略的一个参数。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK