Tuesday, 16 January 2018

Search Results in SharePoint with PnP JavaScript Core Library

Views
SharePoint search provides ways to access the search results using PnP JavaScript core library programming. This post explores the search results, paging option and also describes about the customized wrapper objects available for developers, with #PnPJScore programming.

PnP JS core library provides wrapper object with more customized search results data for developers. Like other programming models like REST API or JSOM, PnP JS core also provides the raw search results as RawSearchResults object. Additionally, PnP JS core also provides few other objects, which is customized for developers. These objects are customized, and retrieved from the RawSearchResults object, which in turn is part of the JSON result.

Search Results Object:


Notable objects are listed below.
  • PrimarySearchResults – This object gets the formatted results from the RawSearchResults object. That is, this object will contain the necessary search results data that can be processed or displayed. It contains the formatted results from the following path.      RawSearchResults.PrimaryQueryResult.RelevantResults.Table.Rows
  • RowCount – Number of rows retrieved during the search query.
  • TotalRows – Number of items available for search query.

Tuesday, 9 January 2018

Building SharePoint Search Queries using PnP JavaScript Core Library

Views
PnP JavaScript core library provides the interfaces required for building the queries for searching SharePoint content.

There are multiple ways of building the queries for PnP JS core search.
  • One way is to use the Search Query interface directly with necessary query parameters
  • The other way is to build the query using Search query builder syntax along with other query parameters.
  • The default way passing just the query text to the search method.

PnP JS core acts as a wrapper for the interacting with the SharePoint data over the object models or the REST APIs available. The samples or syntax explained below are compatible for JavaScript editors.