Share via


Import-SPEnterpriseSearchPopularQueries

Imports queries from a comma-separated list. The search box will suggest these queries as users type.

Syntax

Default (Default)

Import-SPEnterpriseSearchPopularQueries
    -ResultSource <Source>
    -SearchApplicationProxy <SearchServiceApplicationProxyPipeBind>
    -Web <SPWeb>
    [-AssignmentCollection <SPAssignmentCollection>]
    [-Confirm]
    [-Filename <String>]
    [-WhatIf]
    [<CommonParameters>]

Description

The Import-SPEnterpriseSearchPopularQueries cmdlet imports queries from a comma-separated list. As the user types a query in the search box, the search box will suggest queries from the comma-separated list. The search box bases these suggestions on:

  • The SPWeb the search box is located on.
  • The Result Source configured on the search box.

For example, if the search box is located on the "Engineering" SPWeb, the suggested queries will differ from if the search box is located on the "Management" SPWeb. Likewise, if the Result Source on the search box is "Local SharePoint Results", the suggested queries will differ from if the Result Source is "Conversations".

The comma-separated list must consist of one line per query, where each line contains the following items:

Query Text. The actual query expression.

Query Count. The number of times this query was executed.

Click Count. The number of times any user clicked any result for this query.

LCID. The locale identifier (LCID) for the language of the query.

Each line must use the formatting: Query Text,Query Count,Click Count,LCID. For example, Company store,100,80,1033. For suggestions to appear in the search box, the Click Count value must be more than five. The search box ranks query suggestions by their Click Count values (approximately).

For permissions and the most current information about Windows PowerShell for SharePoint Products, see the online documentation at SharePoint Server Cmdlets.

Examples

EXAMPLE

$ssap = Get-SPEnterpriseSearchServiceApplicationProxy
$hostname = hostname
$web = get-spsite | get-spweb | where {$_.Url-eq "https://$hostname"}
$owner = new-object Microsoft.Office.Server.Search.Administration.SearchObjectOwner -ArgumentList @([Microsoft.Office.Server.Search.Administration.SearchObjectLevel]::SPWeb,$web)
$mgr = new-object Microsoft.Office.Server.Search.Administration.Query.FederationManager -ArgumentList $ssap
$source = $mgr.GetSourceByName("Local SharePoint Results", $owner)
Import-SPEnterpriseSearchPopularQueries -SearchApplicationProxy $ssap -Filename C:\input.txt -ResultSource $source -Web $web

This example uses the Import-SPEnterpriseSearchPopularQueries cmdlet to import the queries file that is named C:\input.txt and associate with it the Result Source referenced by $source and the SPWeb referenced by $web. The example defines the variable $web as the SPWeb with URL https://hostname, and the variable $source as the Result Source named "Local SharePoint Results" at the SPWeb referenced by $web.

Parameters

-AssignmentCollection

Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019

Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.

Parameter properties

Type:SPAssignmentCollection
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019

Prompts you for confirmation before executing the command. For more information, type the following command: get-help about_commonparameters

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Filename

Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019

Specifies the full UNC (Universal Naming Convention) path of the file to import.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ResultSource

Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019

Specifies the Result Source to associate with the imported queries. The type must be an instance of a valid Source object.

Parameter properties

Type:Source
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SearchApplicationProxy

Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019

Specifies the proxy for the search application to which the queries file should be imported. The type must be a valid GUID, in the form 12345678-90ab-cdef-1234-567890bcdefgh; a valid search application proxy name (for example, SearchAppProxy1); or an instance of a valid SearchServiceApplicationProxy object.

Parameter properties

Type:SearchServiceApplicationProxyPipeBind
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-Web

Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019

Specifies the SPWeb to associate with the imported queries. The type must be an instance of a valid SPWeb object.

Parameter properties

Type:SPWeb
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019

Displays a message that describes the effect of the command instead of executing the command. For more information, type the following command: get-help about_commonparameters

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.