Welcome!

Industrial IoT Authors: Elizabeth White, Stackify Blog, Yeshim Deniz, SmartBear Blog, Liz McMillan

Blog Feed Post

Getting Started with the Search REST API in SharePoint 2013 Preview

We have a brand new REST based API for interacting with Search in SharePoint 2013 Preview.  Unfortunately, there is not a lot of information out there yet on how to interact with it.  I have pieced together a couple of bits to help get you started.  If you are looking to bring Search into an HTML / JavaScript based application, you’ll be able to get started right away.  The first piece of the puzzle is putting together the right URL to access Search via REST.  To do this, we start with the server name and append /_api/search/query.  Just typing this into the browser will start giving you useful information.  For example:

http://server/_api/search/query

SearchRESTAPIDefault

If you look towards the bottom, you will see the Key SerializedQuery.  This actually shows you the parameters passed into the request.  It also provides you a hint as to what type of parameters you can pass to the REST interface.  The one that might immediately stand out is QueryText.  This is the actual search query.  Think of it as the equivalent of what you type into the search box.  There are a few other parameters that you can customize here as well such as the SummaryLength, MaxSnippetLength. and more.  Let’s try adding QueryText to our URL and passing in a value.

http://server/_api/search/query?querytext=SharePoint

SearchRESTAPIFailedQuery

It turns out the value always has to be enclosed in single quotes (‘) like this:

http://server/_api/search/query?querytext=’SharePoint’

Now, we get some results:

SearchRESTAPIResults

The search results themselves are included in the d:RelevantResults element.  It contains an element d:Table which has   Bare with me as I am going to post the XML for one of the results so that we can inspect it further.

<d:element m:type="SP.SimpleDataRow">

  <d:Cells>

    <d:element m:type="SP.KeyValue">

      <d:Key>Rank</d:Key>

      <d:Value>20.268159866333</d:Value>

      <d:ValueType>Edm.Double</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>DocId</d:Key>

      <d:Value>31</d:Value>

      <d:ValueType>Edm.Int64</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>WorkId</d:Key>

      <d:Value>31</d:Value>

      <d:ValueType>Edm.Int64</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>Title</d:Key>

      <d:Value>Getting the most out of SharePoint Search</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>Author</d:Key>

      <d:Value>Corey Roth;SharePoint Setup</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>Size</d:Key>

      <d:Value>2425342</d:Value>

      <d:ValueType>Edm.Int64</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>Path</d:Key>

      <d:Value>http://sp2010/Shared Documents/Getting the most out of SharePoint Search - SharePoint Saturday Denver.pptx</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>Description</d:Key>

      <d:Value>

        Template: Sam Moore; Silver Fox Productions, Inc.&#xD;

        Formatting:&#xD;

        Event Date: October 3-6th, 2011&#xD;

        Event Location: Anaheim, CA&#xD;

        Audience Type: Internal/External

      </d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>Write</d:Key>

      <d:Value>2011-11-10T00:00:00.0000000</d:Value>

      <d:ValueType>Edm.DateTime</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>CollapsingStatus</d:Key>

      <d:Value>0</d:Value>

      <d:ValueType>Edm.Int64</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>HitHighlightedSummary</d:Key>

      <d:Value xml:space="preserve">Passed all &lt;c0&gt;SharePoint&lt;/c0&gt; 2010 certification exams &lt;ddd/&gt; Introduce Search in &lt;c0&gt;SharePoint&lt;/c0&gt; Online &lt;ddd/&gt; The talk will be slides with quite a few demos of &lt;c0&gt;SharePoint&lt;/c0&gt; Online features &lt;ddd/&gt; </d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>HitHighlightedProperties</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>contentclass</d:Key>

      <d:Value>STS_ListItem_DocumentLibrary</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>PictureThumbnailURL</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>ServerRedirectedURL</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>ServerRedirectedEmbedURL</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>ServerRedirectedPreviewURL</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>FileExtension</d:Key>

      <d:Value>pptx</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>ContentTypeId</d:Key>

      <d:Value>0x010100B1CF83A7F86DFC468C975FFF33126DFD</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>ParentLink</d:Key>

      <d:Value>http://sp2010/Shared Documents/Forms/AllItems.aspx</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>ViewsLifeTime</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>ViewsRecent</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>SectionNames</d:Key>

      <d:Value xml:space="preserve">Getting the most out of SharePoint Search&#xD;

;Getting the most out of SharePoint Search&#xD;

;Corey Roth&#xD;

About me&#xD;

;Key Theme&#xD;

;SharePoint is not a…&#xD;

;SharePoint is a…&#xD;

;Challenges with Search&#xD;

;Agenda&#xD;

;Key Takeaways&#xD;

;You have a choice…&#xD;

;What can search index?&#xD;

;Search in SharePoint&#xD;

;Components of Search&#xD;

;Finding things easier…&#xD;

;Improve search with queries&#xD;

;Built-in Managed Properties&#xD;

;Segmenting results with Scopes&#xD;

;Querying Search and Scopes&#xD;

;Provide more search options&#xD;

;Many options for displaying scopes&#xD;

</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>SectionIndexes</d:Key>

      <d:Value>1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>SiteLogo</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>SiteDescription</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>deeplinks</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>importance</d:Key>

      <d:Value>0</d:Value>

      <d:ValueType>Edm.Int64</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>SiteName</d:Key>

      <d:Value>http://sp2010</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>IsDocument</d:Key>

      <d:Value>true</d:Value>

      <d:ValueType>Edm.Boolean</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>LastModifiedTime</d:Key>

      <d:Value>2011-11-10T00:00:00.0000000</d:Value>

      <d:ValueType>Edm.DateTime</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>FileType</d:Key>

      <d:Value>pptx</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>IsContainer</d:Key>

      <d:Value>false</d:Value>

      <d:ValueType>Edm.Boolean</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>WebTemplate</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>SecondaryFileExtension</d:Key>

      <d:Value>pptx</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>OriginalPath</d:Key>

      <d:Value>http://sp2010/Shared Documents/Getting the most out of SharePoint Search - SharePoint Saturday Denver.pptx</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>DisplayAuthor</d:Key>

      <d:Value>Corey Roth;SharePoint Setup</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>Created</d:Key>

      <d:Value>2012-07-26T23:21:29.0000000</d:Value>

      <d:ValueType>Edm.DateTime</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>PeopleInMedia</d:Key>

      <d:Value></d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>MediaDuration</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>PictureWidth</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>PictureHeight</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>DefaultEncodingURL</d:Key>

      <d:Value>http://sp2010/Shared%20Documents/Getting%20the%20most%20out%20of%20SharePoint%20Search%20-%20SharePoint%20Saturday%20Denver.pptx</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>ExternalMediaURL</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>UserEncodingURL</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>Community_MembersCount</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>Community_RepliesCount</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>Community_TopicsCount</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>ReplyCount</d:Key>

      <d:Value>0</d:Value>

      <d:ValueType>Edm.Int64</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>LikesCount</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>Discussion_BestAnswerID</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>Discussion_Category</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>Discussion_Post</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>Discussion_LikesCount</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>ListItemID</d:Key>

      <d:Value>6</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>FullPostBody</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>PostAuthor</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>RootPostOwnerID</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>RootPostID</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>AttachmentType</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>AttachmentURI</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>MicroBlogType</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>ModifiedBy</d:Key>

      <d:Value>

        Corey Roth

 

        SharePoint Setup

      </d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>RootPostUniqueID</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>Tags</d:Key>

      <d:Value></d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>ImageDateCreated</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>PictureURL</d:Key>

      <d:Value m:null="true" />

      <d:ValueType>Null</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>ResultTypeIdList</d:Key>

      <d:Value>2;6</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>PartitionId</d:Key>

      <d:Value>0c37852b-34d0-418e-91c6-2ac25af4be5b</d:Value>

      <d:ValueType>Edm.Guid</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>UrlZone</d:Key>

      <d:Value>0</d:Value>

      <d:ValueType>Edm.Int32</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>AAMEnabledManagedProperties</d:Key>

      <d:Value>HierarchyUrl;OrgParentUrls;OrgUrls;OriginalPath;Path;recommendedfor;SitePath</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>ResultTypeId</d:Key>

      <d:Value>2</d:Value>

      <d:ValueType>Edm.Int32</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>RenderTemplateId</d:Key>

      <d:Value>~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_PowerPoint.js</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

    <d:element m:type="SP.KeyValue">

      <d:Key>piSearchResultId</d:Key>

      <d:Value>1_1</d:Value>

      <d:ValueType>Edm.String</d:ValueType>

    </d:element>

  </d:Cells>

</d:element>

As you can see, we now get a ton of information back from Search for a given search result.  Let me point out some of the more interesting values.  We have the usual values such as Title, Path, Author, Write (Modified Date), and HitHighlightedSummary.  However, we also get a ton of new information.  For images, you will get a PictureThumbnailUrl to allow you to easily show a thumbnail.  This particular result is a PowerPoint and search understands the individual sections inside it now which you will see in SectionNamesSiteName provides the site hosting the item.  Tags will provide any use of the Enterprise Keywords field.  You also get a heap of social information about the item as well such as how many likes.  Lastly, the RenderTemplateId tells you which template the result source is using to display it on the search results page.  This is just one example, but you can see we get a lot of useful information about the search.

Looking at the XML in the browser is a great way to get familiar with what the API has to offer.  When you are ready to start developing, it is very easy to take advantage of the REST API using JavaScript.  You can do this with the $.ajax() method in jQuery and pass in the URL you used in the browser.  You want to use the GET method and pass in a header telling it you want the results back as json.  They have a good example of how this works on code.msdn.microsoft.com.  Specifically, take a look at App.js in the example to see the code in action.  It’s pretty simple.

If you want to take advantage of the REST API from C# or another .NET language, that is another story though.  I haven’t been able to add a service reference for the REST API.  All of the server side code examples I have seen call the REST API using HttpWebRequest which requires no less than 60 lines of code or so.  I am hoping there is a better way but I haven’t seen one yet.  If you have had better luck be sure and let me know.

Read the original blog entry...

More Stories By Corey Roth

Corey Roth, a SharePoint Server MVP, is an independent consultant specializing in Cloud technologies such as Azure and Office 365. He also specializes in mobile development. Corey serves as the product manager for two cloud-first mobile app platforms: BrewZap and HappenZap.

IoT & Smart Cities Stories
Headquartered in Plainsboro, NJ, Synametrics Technologies has provided IT professionals and computer systems developers since 1997. Based on the success of their initial product offerings (WinSQL and DeltaCopy), the company continues to create and hone innovative products that help its customers get more from their computer applications, databases and infrastructure. To date, over one million users around the world have chosen Synametrics solutions to help power their accelerated business or per...
Poor data quality and analytics drive down business value. In fact, Gartner estimated that the average financial impact of poor data quality on organizations is $9.7 million per year. But bad data is much more than a cost center. By eroding trust in information, analytics and the business decisions based on these, it is a serious impediment to digital transformation.
@DevOpsSummit at Cloud Expo, taking place November 12-13 in New York City, NY, is co-located with 22nd international CloudEXPO | first international DXWorldEXPO and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time t...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things'). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing. IoT is not about the devices, its about the data consumed and generated. The devices are tools, mechanisms, conduits. This paper discusses the considerations when dealing with the...
SYS-CON Events announced today that IoT Global Network has been named “Media Sponsor” of SYS-CON's @ThingsExpo, which will take place on June 6–8, 2017, at the Javits Center in New York City, NY. The IoT Global Network is a platform where you can connect with industry experts and network across the IoT community to build the successful IoT business of the future.
IoT is rapidly becoming mainstream as more and more investments are made into the platforms and technology. As this movement continues to expand and gain momentum it creates a massive wall of noise that can be difficult to sift through. Unfortunately, this inevitably makes IoT less approachable for people to get started with and can hamper efforts to integrate this key technology into your own portfolio. There are so many connected products already in place today with many hundreds more on the h...
The best way to leverage your Cloud Expo presence as a sponsor and exhibitor is to plan your news announcements around our events. The press covering Cloud Expo and @ThingsExpo will have access to these releases and will amplify your news announcements. More than two dozen Cloud companies either set deals at our shows or have announced their mergers and acquisitions at Cloud Expo. Product announcements during our show provide your company with the most reach through our targeted audiences.
CloudEXPO New York 2018, colocated with DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to one location.
Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settlement products to hedge funds and investment banks. After, he co-founded a revenue cycle management company where he learned about Bitcoin and eventually Ethereal. Andrew's role at ConsenSys Enterprise is a mul...
Disruption, Innovation, Artificial Intelligence and Machine Learning, Leadership and Management hear these words all day every day... lofty goals but how do we make it real? Add to that, that simply put, people don't like change. But what if we could implement and utilize these enterprise tools in a fast and "Non-Disruptive" way, enabling us to glean insights about our business, identify and reduce exposure, risk and liability, and secure business continuity?