![]() ![]() Call our Load-function which will post the actual query ![]() $("#searchResults").html("An error occured" + JSON.stringify(err)) Var clickableLink = "" + + "Type: " + + "Modified: " + currentDate + "" "accept": "application/json odata=verbose", SPSearchResults.url = _spPageContextInfo.webAbsoluteUrl + "/_api/search/query?querytext='" + query + "'" I’ve added a file to the project called RestSearch.js, which is a custom javascript file containing the following code which will perform an ajax request to SharePoint using the Search API’s: // in reality we should put this inside our own namespace, but this is just a sample. ASP.NET Markup SnippetĪs we can see in the following code snippet, we’re simply loading a few jQuery and JavaScript files that we require and we define a Search Box and a Button for controlling our little Search application. Let’s see what a very simple application could look like, utilizing the SharePoint 2013 rest search api’s. We can then use the result of this query in our application in whatever fashion we want. ](/co et/content/images/2012/12/image_thumb11.png)Įssentially we’re getting a bunch of XML returned from the query which we then have to parse and handle somehow. If you simply want to return all results with no limits or filters from a search, shoot out this formatted url: Formatting the Urlīy formatting the Url properly you can retrieve search results pretty easily using REST. Let’s examine how you can construct your search queries using REST formatting and by simply changing the URL to take in the proper query strings. ( GHOST_URL/content/imag et/content/images/2012/12/image5.png) Creating a Search Application using REST Search Api’s In my example I’ve created a custom Page which loads my jQuery and JavaScript files, and I’m deploying those files using a Module to the SiteAssets library. The approach mentioned in this post is also compatible with SharePoint Apps, should you decide to develop an App that relys on Search. So in order to get started, we’ll need to have an ASPX Page containing some simple markup and a javascript file where we’ll put our functions to be executed. In this post I’ll show a simple example of how you can utilize the REST Search API’s in SharePoint 2013 to perform a search. With SharePoint 2013, the search capabilities are heavily invested in and we see a lot of new ways to perform our searches. Search has always been a great way to create custom solutions that aggregate and finds information in SharePoint. □ TIP: Check out the guidance for building sustainable Azure workloads! □ ![]()
0 Comments
Leave a Reply. |