Set-SPEnterpriseSearchResultItemType

Sets properties of a result item type.

Syntax

Set-SPEnterpriseSearchResultItemType
   [-Identity] <ResultItemTypePipeBind>
   -Owner <SearchObjectOwner>
   [-AssignmentCollection <SPAssignmentCollection>]
   [-Confirm]
   [-DisplayProperties <String>]
   [-DisplayTemplateUrl <String>]
   [-Name <String>]
   [-OptimizeForFrequentUse <Boolean>]
   [-RulePriority <Int32>]
   [-Rules <PropertyRuleCollection>]
   [-SearchApplication <SearchServiceApplicationPipeBind>]
   [-SearchApplicationProxy <SearchServiceApplicationProxyPipeBind>]
   [-SourceID <Guid>]
   [-WhatIf]
   [<CommonParameters>]

Description

The Set-SPEnterpriseSearchResultItemType cmdlet sets properties of user-created result item types. You cannot use this cmdlet to set or change properties of the built-in result item types that are included with SharePoint products.

Result item types enable you to change the look of search results based on the type of result. You start by defining a collection of rules, which will be evaluated against the properties of results. Then you define the display template to use for rendering that type of result. Once you have created the result item type, results matching the rules of the result item type will render using the specified display template.

Example use cases:

  • Change the look of results for a particular file name extension, for example Word documents.
  • Change the look of a particular content type in search results.
  • Change the look of results from a particular author.
  • Add a result action to results from a particular result source as part of a custom search application.

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

Examples

--------------------EXAMPLE---------------------

$web = Get-SPWeb https://webUrl
$tenantOwner = Get-SPEnterpriseSearchOwner -Level SPSite -SPWeb $web
$ssa = Get-SPEnterpriseSearchServiceApplication
$resultType = Get-SPEnterpriseSearchResultItemType -Owner $tenantOwner -SearchApplication $ssa
$resultType.BuiltIn
$rule = Get-SPEnterpriseSearchPropertyRule -PropertyName "ContentTypeId" -Operator "StartsWith"
$rule.AddValue('0x010063C2F478ACC511DFB869B5BFDFD720851252')
$ruleCollection = Get-SPEnterpriseSearchPropertyRuleCollection
$ruleCollection.Add($rule)
$displayProperties = "WorkId,Rank,Title,Size,Path,Description,SiteName,HitHighlightedSummary,HitHighlightedProperties,ViewsLifeTime"
$displaytemplateUrl = "~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_MyCustomDisplayTemplate.js"
Set-SPEnterpriseSearchResultItemType 
-Identity $resultType `
-SearchApplication $ssa `
-Name "CustomResultType" `
-Rules $ruleCollection `
-RulePriority 1 
-DisplayProperties $displayProperties `
-DisplayTemplateUrl $displaytemplateUrl `
-Owner $tenantOwner

This example first defines variables for the URL of the site, the search owner and search application. It retrieves the result item type and checks whether the result item type is a built-in result item type. If $resultType.BuiltIn returns false then the result item type is not built-in and you can set its properties by using the Set-SPEnterpriseSearchResultItemType.

Next, the example creates the rule that result item types shall be matched against and adds it to a property rule collection.

Next, the example defines which properties of the result item type that shall be displayed and the display template to use.

Finally, the example uses the Set-SPEnterpriseSearchResultItemType cmdlet to modify the result item type.

Parameters

-AssignmentCollection

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.

Type:SPAssignmentCollection
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Confirm

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

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-DisplayProperties

Specifies which result properties to display.

Type:String
Aliases:dp
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-DisplayTemplateUrl

Specifies the URL of the display template that shall be used for rendering the results.

Type:String
Aliases:url
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Identity

Specifies the result item type to update. The type must be a valid GUID, in the form 12345678-90ab-cdef-1234-567890bcdefgh.

Type:ResultItemTypePipeBind
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Name

Specifies the name of the result item type.

Type:String
Aliases:n
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-OptimizeForFrequentUse

{{ Fill OptimizeForFrequentUse Description }}

Type:Boolean
Aliases:opt
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Owner

Specifies the search object owner that defines the scope at which the result item type was created.

Type:SearchObjectOwner
Aliases:o
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-RulePriority

Specifies which priority the collection of rules has compared to other rules.

Type:Int32
Aliases:priority
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Rules

Specifies the collection of rules to evaluate the result properties against.

Type:PropertyRuleCollection
Aliases:rule
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-SearchApplication

Specifies the name of the search application. The type must be a valid GUID, in the form 12345678-90ab-cdef-1234-567890bcdefgh; a valid search application name (for example, SearchApp1); or an instance of a valid SearchServiceApplication object.

Type:SearchServiceApplicationPipeBind
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-SearchApplicationProxy

Specifies the proxy of the search application that contains the result item type. 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.

Type:SearchServiceApplicationProxyPipeBind
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-SourceID

Identifies the search result source that the result item type applies to.

Type:Guid
Aliases:sid
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-WhatIf

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

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition