8

SharePoint Search REST API 获取数据

 3 years ago
source link: https://www.cnblogs.com/jianyus/p/13276660.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 Search REST API 获取数据

  前言

  最近,需要做一个知识管理的系统,所以,就需要调用SharePoint Search REST API了,其实,ajax调用REST API是非常简单的,大家可以参考下。

  正文

  废话不多说,直接上代码:

$.ajax({
    url: "https://sitecollection/_api/search/query?querytext='key words'&sourceid='5231ddab-4d30-4b0d-9f1f-33bb80545bfb'",
    headers: {
        "Accept": "application/json; odata=verbose"
    },
    contentType: "application/json; odata=verbose",
    success: function(data) {
        console.log(data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results);
    }
});

querytext属性,顾名思义,就是查询关键字了,我们搜索和全文检索的关键字。

sourceid,搜索结果源的ID,搜索结果源是什么?

我理解的搜索结果源,就是对于搜索结果的一个过滤器,可以按照我们的要求进行排序、筛选等操作。

无论想添加查询条件,还是限制搜索范围,都可以通过搜索结果源快速实现。

具体搜索结果源的配置,可以在网站设置里,进行配置,很简单的。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK