Grokking search via CSOM/JSOM and REST 
Mikael Svenson 
August 22 2014 
DNV GL © 2014 
DRAFT 
August 22 2014 SAFER, SMARTE...
CSOM/JSOM 
 Client Side Object Model 
 JavaScript object model 
 http://msdn.microsoft.com/en-us/library/office/dn42322...
jQuery.ajax({ 
DNV GL © 2014 
DRAFT 
August 22 2014 
REST 
 http://msdn.microsoft.com/en-us/library/office/jj163876(v=off...
SharePoint 2013 Search Query Tool 
 https://sp2013searchtool.codeplex.com/ 
DNV GL © 2014 
DRAFT 
August 22 2014 
4
Fiddler or similar to explore the JSON data 
DNV GL © 2014 
DRAFT 
August 22 2014 
5
Benefits of using CSOM 
 You can batch queries, optimizing query execution 
DNV GL © 2014 
DRAFT 
August 22 2014 
6
Batching with REST 
 Can be achieved using query rules and result blocks, but will limit the number of 
results per type ...
Refiners with REST 
 Use the query tool 
 Specify the refiners you want returned 
 Pick values from the Refinement resu...
Refiners in CSOM 
 Similar to REST, set the .Refiners property of the KeywordQuery object 
 Set the RefinementFilters pr...
Anonymous 
 Requires some configuration 
 http://msdn.microsoft.com/en-us/ 
library/office/jj163876(v=office.15).aspx#bk...
Questions? 
SAFER, SMARTER, GREENER 
DNV GL © 2014 
DRAFT 
August 22 2014 
www.dnvgl.com 
11
Upcoming SlideShare
Loading in …5
×

Share point – client search api’s

786 views

Published on

Small presentation on the client search API's available which I did for my team at DNVGL.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
786
On SlideShare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Share point – client search api’s

  1. 1. Grokking search via CSOM/JSOM and REST Mikael Svenson August 22 2014 DNV GL © 2014 DRAFT August 22 2014 SAFER, SMARTER, GREENER SOFTWARE SharePoint – Client Search API’s 1
  2. 2. CSOM/JSOM  Client Side Object Model  JavaScript object model  http://msdn.microsoft.com/en-us/library/office/dn423226(v=office.15).aspx DNV GL © 2014 DRAFT August 22 2014 2
  3. 3. jQuery.ajax({ DNV GL © 2014 DRAFT August 22 2014 REST  http://msdn.microsoft.com/en-us/library/office/jj163876(v=office.15).aspx  Wrapper functions will help: http://www.skylinetechnologies.com/Blog/Article/2480/Using-the-SharePoint- 2013-Search-REST-API.aspx 3 url: webUrl + "/_api/search/query?querytext='SharePoint'&rowlimit=10", type: "GET", headers: { "Accept": "application/json;odata=verbose" }, success: function (data) { var hitCount = data.d.query.PrimaryQueryResult.RelevantResults.TotalRows; var hitCountwithDuplicates = data.d.query.PrimaryQueryResult.RelevantResults.TotalRowsIncludingDuplicates; var results = data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results; $.each(results, function () { $.each(this.Cells.results, function () { var propertyName = this.Key; var propertyValue = this.Value; }); }); /* get result blocks */ if (data.d.query.SecondaryQueryResults != null) { for (var i = 0; i < data.d.query.SecondaryQueryResults.results.length; i++) { var resultBlock = data.d.query.SecondaryQueryResults.results[i]; $.each(resultBlock.RelevantResults.Table.Rows.results, function () { $.each(this.Cells.results, function () { var propertyName = this.Key; var propertyValue = this.Value; }); }); } } }, error: function (data) { } });
  4. 4. SharePoint 2013 Search Query Tool  https://sp2013searchtool.codeplex.com/ DNV GL © 2014 DRAFT August 22 2014 4
  5. 5. Fiddler or similar to explore the JSON data DNV GL © 2014 DRAFT August 22 2014 5
  6. 6. Benefits of using CSOM  You can batch queries, optimizing query execution DNV GL © 2014 DRAFT August 22 2014 6
  7. 7. Batching with REST  Can be achieved using query rules and result blocks, but will limit the number of results per type to 10  That said, using a query rule with result blocks makes updates a lot easier if you need to change the search queries – Example: Intranet front page which shows – Top 4 articles – Top X blog posts – Latest user documents – etc DNV GL © 2014 DRAFT August 22 2014 7
  8. 8. Refiners with REST  Use the query tool  Specify the refiners you want returned  Pick values from the Refinement results table  Use the Refinement Token value and(ContentType:ǂǂ746578742f68746d6c3b20636861727365743d7574662d38,FileType:ǂǂ68746d6c)  The value is hex encoded and(ContentType:"text/html; charset=utf-8",FileType:html) DNV GL © 2014 DRAFT August 22 2014 8
  9. 9. Refiners in CSOM  Similar to REST, set the .Refiners property of the KeywordQuery object  Set the RefinementFilters property to add filters RefinementFilters.Add(<filter>)  http://techmikael.blogspot.no/2013/07/working-with-refiners-in-csomsharepoint. DNV GL © 2014 DRAFT html August 22 2014 9
  10. 10. Anonymous  Requires some configuration  http://msdn.microsoft.com/en-us/ library/office/jj163876(v=office.15).aspx#bk_AnonymousREST  Waldek Mastykarz is your man when it comes to anonymous and WCM  http://blog.mastykarz.nl/configuring-sharepoint-2013-search-rest-api-anonymous-  http://blog.mastykarz.nl/inconvenient-search-rest-api-anonymous-users/  http://blog.mastykarz.nl/debugging-setting-properties-anonymous-search-rest-queries/ DNV GL © 2014 DRAFT users/ August 22 2014 10
  11. 11. Questions? SAFER, SMARTER, GREENER DNV GL © 2014 DRAFT August 22 2014 www.dnvgl.com 11

×