1

I wonder which QueryTemplate available to use with pnp.sp.search?

For right now I find only one property :"(IsDocument:True)"

 pnp.sp.search({
                Querytext: query,
                RowLimit: 20,
                StartRow: 0,
                SelectProperties: ["Title", "Author", "Path", "FileType", "RefinersTextListOWSTEXT"],
                QueryTemplate: "(IsDocument: True)"
            })
6
  • Hi @Ann, does my below answer help you in any way? Commented Jan 11, 2023 at 11:39
  • Hi @GaneshSanap is it work like "Author" - name of contentipe, 'johndoe' - value
    – Ann
    Commented Jan 11, 2023 at 11:42
  • If you want to add query based on content type, you can use it like: {searchTerms} contenttype:picture Commented Jan 11, 2023 at 11:43
  • @GaneshSanap "Author" and contenttype is a managed properties?
    – Ann
    Commented Jan 11, 2023 at 11:58
  • 1
    List of all standard properties learn.microsoft.com/en-us/sharepoint/technical-reference/…
    – Ann
    Commented Jan 13, 2023 at 14:24

1 Answer 1

1

QueryTemplate is a string that contains the text that replaces the query text, as part of a query transform.

Source: QueryTemplate

It allows other properties as well like:

{
  '__metadata': {
      'type': 'Microsoft.Office.Server.Search.REST.SearchRequest'
   },
  'Querytext': 'sharepoint',
  'QueryTemplate': '{searchterms} Author:johndoe'
}

You can also use query variable like {User.Name}, {Site.URL}, etc. Check list of query variables at:

  1. Understanding query transforms
  2. Query variables in SharePoint

Update from comments:

You can find list of all standard properties at: Overview of crawled and managed properties in SharePoint Server - few properties might not be available in SharePoint online

1
  • It must be wright a little bit different QueryTemplate:"(Title='test')"
    – Ann
    Commented Jan 11, 2023 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.