Forum Discussion

Mike Jansen's avatar
Mike Jansen
Iron Contributor
Oct 06, 2017

pnp.sp.search > syntax question (from SharePoint search API URL to PnP)

For the first time I do some testing using pnp.sp.search. 

My first simple test is like this:

pnp.sp.search("SharePoint").then((result : SearchResults)

Now I want to convert an api search to pnp. My query is like this:

https://blabla.sharepoint.com/sites/test/_api/search/query?querytext='ContentType:TEST_matters'&refinementfilters='RefinableString18:equals("false")'

I've done some searching on the internet to find the syntax to covert this to pnp but no luck so far.

 

So how do I change my querystring in order to get it working with PnP?

 

Thanks, Mike

  • Got it!! I tried to put the filter in the querytekst. Seems to be a wrong approach. This is the working code:

     pnp.sp.search(<SearchQuery>{
          Querytext: "ContentType:TEST_matters",
          RowLimit: 10,
          EnableInterleaving: true,
          RefinementFilters: ["RefinableString18:equals('false')"],
          }).then((result: SearchResults) =>
    • Mike Jansen's avatar
      Mike Jansen
      Iron Contributor

      Hi Patrick Rodgers. I tried this but it looks like I'm doing something wrong.

       

      pnp.sp.search(<SearchQuery>{    Querytext: "ContentType:TEST_matters&refinementfilters=RefinableString18:equals("false")",
          RowLimit: 10,
          EnableInterleaving: true,
      }).then((r: SearchResults)

      Can you help me out here?

      Thanks

      • Mike Jansen's avatar
        Mike Jansen
        Iron Contributor

        Got it!! I tried to put the filter in the querytekst. Seems to be a wrong approach. This is the working code:

         pnp.sp.search(<SearchQuery>{
              Querytext: "ContentType:TEST_matters",
              RowLimit: 10,
              EnableInterleaving: true,
              RefinementFilters: ["RefinableString18:equals('false')"],
              }).then((result: SearchResults) =>

Resources