This SharePoint 2013 tutorial, I’ll go through the details of the SharePoint 2013 Search REST API. This new REST service is the best way to go in a variety of application scenarios. SharePoint Apps built-in JavaScript is one good example. External Applications to SharePoint that require search functionality; can also leverage this service as the endpoint for communication into the Search platform.
New to Office 365 SharePoint Online? Get Office 365 Enterprise E3 Subscription & Try out all the features
The old search.asmx SOAP web service is marked as deprecated in SP2013, and the new Search REST service is the replacement.
Location of the Search Rest service:
The Search REST service is located at the following URI: http://host/site/_api/search
The Search REST API:
The Search REST service exposed by the URI specified above provides the following methods or entry points:
The new Result Source feature in SharePoint 2013 is really cool, writing queries against them is not. With scopes, you could specify them by name (i.e.: All Sites or People). However, with result sources, you must specify the id, not the name. This cane makes it tricky to develop custom coded solutions. In comparing an on-premises installation of SharePoint 2013 with a SharePoint Online Preview tenant, here is the list I came up with. Hopefully, it will save you some time when you need to write a query.
Result Source | ID |
Documents | e7ec8cee-ded8-43c9-beb5-436b54b31e84 |
Items matching a content type | 5dc9f503-801e-4ced-8a2c-5d1237132419 |
Items matching a tag | e1327b9c-2b8c-4b23-99c9-3730cb29c3f7 |
Items related to current user | 48fec42e-4a92-48ce-8363-c2703a40e67d |
Items with same keyword as this item | 5c069288-1d17-454a-8ac6-9c642a065f48 |
Local People Results | b09a7990-05ea-4af9-81ef-edfab16c4e31 |
Local Reports And Data Results | 203fba36-2763-4060-9931-911ac8c0583b |
Local SharePoint Results | 8413cd39-2156-4e00-b54d-11efd9abdb89 |
Local Video Results | 78b793ce-7956-4669-aa3b-451fc5defebf |
Pages | 5e34578e-4d08-4edc-8bf3-002acf3cdbcc |
Pictures | 38403c8c-3975-41a8-826e-717f2d41568a |
Popular | 97c71db1-58ce-4891-8b64-585bc2326c12 |
Recently changed items | ba63bbae-fa9c-42c0-b027-9a878f16557c |
Recommended Items | ec675252-14fa-4fbe-84dd-8d098ed74181 |
Wiki | 9479bf85-e257-4318-b5a8-81a180f5faa1 |
Example : set a search scope: People:
<script>
$(document).ready(function(){
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl +“?querytext=’*’&sourceid=’b09a7990-05ea-4af9-81ef-edfab16c4e31′” +
“&selectproperties=’AccountName’,PictureURL,PreferredName’” +“&rowlimit=99”,
method: “GET”,
headers: { “Accept”: “application/json; odata=verbose” },
cache: false,
success: function (result) {
} // success function
});//.ajax
});//docReady
<scrip>
You may like following SharePoint 2013 search tutorials:
- The Search Service is currently offline in SharePoint 2010 search
- Query Search with SharePoint 2013 JavaScript client object model
- Query Search with SharePoint 2013 Client Object Model
- Query Search with SharePoint 2013 server object model
- How to configure SharePoint Server 2010 Search to crawl files in share folder?
- How to define Search scopes in SharePoint 2013 Using Result Sources?
- Search People as a Search Scope or Content Source Using SharePoint 2013 REST API
Hope this SharePoint 2013 tutorial explains, SharePoint 2013 search Query APIs or SharePoint 2013 Rest API.