Submit-PnPSearchQuery

Executes an arbitrary search query against the SharePoint search index

Syntax

Submit-PnPSearchQuery
      -Query <String>
                           [-StartRow <Int>]
                           [-MaxResults <Int>]
                           [-TrimDuplicates <Boolean>]
                           [-Properties <Hashtable>]
                           [-Refiners <String>]
                           [-Culture <Int>]
                           [-QueryTemplate <String>]
                           [-SelectProperties <String[]>]
                           [-RefinementFilters <String[]>]
                           [-SortList <Hashtable>]
                           [-RankingModelId <String>]
                           [-ClientType <String>]
                           [-CollapseSpecification <String>]
                           [-HiddenConstraints <String>]
                           [-TimeZoneId <Int>]
                           [-EnablePhonetic <Boolean>]
                           [-EnableStemming <Boolean>]
                           [-EnableQueryRules <Boolean>]
                           [-SourceId <Guid>]
                           [-ProcessBestBets <Boolean>]
                           [-ProcessPersonalFavorites <Boolean>]
                           [-RelevantResults [<SwitchParameter>]]
                           [-Web <WebPipeBind>]
                           [-Connection <SPOnlineConnection>]
Submit-PnPSearchQuery
      -Query <String>
                           [-All [<SwitchParameter>]]
                           [-TrimDuplicates <Boolean>]
                           [-Properties <Hashtable>]
                           [-Refiners <String>]
                           [-Culture <Int>]
                           [-QueryTemplate <String>]
                           [-SelectProperties <String[]>]
                           [-RefinementFilters <String[]>]
                           [-SortList <Hashtable>]
                           [-RankingModelId <String>]
                           [-ClientType <String>]
                           [-CollapseSpecification <String>]
                           [-HiddenConstraints <String>]
                           [-TimeZoneId <Int>]
                           [-EnablePhonetic <Boolean>]
                           [-EnableStemming <Boolean>]
                           [-EnableQueryRules <Boolean>]
                           [-SourceId <Guid>]
                           [-ProcessBestBets <Boolean>]
                           [-ProcessPersonalFavorites <Boolean>]
                           [-RelevantResults [<SwitchParameter>]]
                           [-Web <WebPipeBind>]
                           [-Connection <SPOnlineConnection>]

Examples

------------------EXAMPLE 1------------------

Submit-PnPSearchQuery -Query "finance"

Returns the top 500 items with the term finance

------------------EXAMPLE 2------------------

Submit-PnPSearchQuery -Query "Title:Intranet*" -MaxResults 10

Returns the top 10 items indexed by SharePoint Search of which the title starts with the word Intranet

------------------EXAMPLE 3------------------

Submit-PnPSearchQuery -Query "Title:Intranet*" -All

Returns absolutely all items indexed by SharePoint Search of which the title starts with the word Intranet

------------------EXAMPLE 4------------------

Submit-PnPSearchQuery -Query "Title:Intranet*" -Refiners "contentclass,FileType(filter=6/0/*)"

Returns absolutely all items indexed by SharePoint Search of which the title starts with the word Intranet, and return refiners for contentclass and FileType managed properties

Parameters

-All

Automatically page results until the end to get more than 500. Use with caution!

Type:SwitchParameter
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-ClientType

Specifies the name of the client which issued the query.

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-CollapseSpecification

Limit the number of items per the collapse specification. See https://docs.microsoft.com/en-us/sharepoint/dev/general-development/customizing-search-results-in-sharepoint#collapse-similar-search-results-using-the-collapsespecification-property for more information.

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Connection

Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

Type:SPOnlineConnection
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Culture

The locale for the query.

Type:Int
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-EnablePhonetic

Specifies whether the phonetic forms of the query terms are used to find matches.

Type:Boolean
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-EnableQueryRules

Specifies whether Query Rules are enabled for this query.

Type:Boolean
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-EnableStemming

Specifies whether stemming is enabled.

Type:Boolean
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-HiddenConstraints

The keyword query’s hidden constraints.

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-MaxResults

Maximum amount of search results to return. Default and max per page is 500 search results.

Type:Int
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-ProcessBestBets

Determines whether Best Bets are enabled.

Type:Boolean
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-ProcessPersonalFavorites

Determines whether personal favorites data is processed or not.

Type:Boolean
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Properties

Extra query properties. Can for example be used for Office Graph queries.

Type:Hashtable
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Query

Search query in Keyword Query Language (KQL).

Type:String
Position:0
Accept pipeline input:True
Accept wildcard characters:False
-QueryTemplate

Specifies the query template that is used at run time to transform the query based on user input.

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-RankingModelId

The identifier (ID) of the ranking model to use for the query.

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-RefinementFilters

The set of refinement filters used.

Type:String[]
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Refiners

The list of refiners to be returned in a search result.

Type:String
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-RelevantResults

Specifies whether only relevant results are returned

Type:SwitchParameter
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-SelectProperties

The list of properties to return in the search results.

Type:String[]
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-SortList

The list of properties by which the search results are ordered.

Type:Hashtable
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-SourceId

Specifies the identifier (ID or name) of the result source to be used to run the query.

Type:Guid
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-StartRow

Search result item to start returning the results from. Useful for paging. Leave at 0 to return all results.

Type:Int
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-TimeZoneId

The identifier for the search query time zone.

Type:Int
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-TrimDuplicates

Specifies whether near duplicate items should be removed from the search results.

Type:Boolean
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-Web

This parameter allows you to optionally apply the cmdlet action to a subweb within the current web. In most situations this parameter is not required and you can connect to the subweb using Connect-PnPOnline instead. Specify the GUID, server relative url (i.e. /sites/team1) or web instance of the web to apply the command to. Omit this parameter to use the current web.

Type:WebPipeBind
Position:Named
Accept pipeline input:False
Accept wildcard characters:False

Outputs

List<System.Object>