Set-SPEnterpriseSearchResultItemType
设置结果项类型的属性。
语法
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>]
说明
cmdlet Set-SPEnterpriseSearchResultItemType
设置用户创建的结果项类型的属性。
不能使用此 cmdlet 设置或更改 SharePoint 产品中包含的内置结果项类型的属性。
使用结果项类型,可以根据结果类型更改搜索结果的外观。 首先定义规则集合,这些规则将根据结果的属性进行评估。 然后定义用于呈现该类型结果的显示模板。 创建结果项类型后,与结果项类型规则匹配的结果将使用指定的显示模板呈现。
用例示例:
- 更改特定文件扩展名(例如 Word 文档)的结果外观。
- 更改搜索结果中特定内容类型的外观。
- 更改特定作者的结果的外观。
- 将一个结果操作从作为自定义搜索应用程序一部分的特定结果源添加到结果中。
有关适用于 SharePoint 产品的 Windows PowerShell 的权限和最新信息,请参阅 SharePoint Server cmdlet。
示例
--------------------示例---------------------
$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
此示例首先定义网站的 URL、搜索所有者和搜索应用程序的变量。
它检索结果项类型并检查该类型是否为内置结果项类型。
如果 $resultType.BuiltIn 返回 false,则结果项类型不是内置类型,可以使用 设置其属性 Set-SPEnterpriseSearchResultItemType
。
接下来,该示例创建结果项类型应匹配的规则,并将其添加到属性规则集合中。
紧接着,此示例定义应显示的结果项类型属性以及要使用的显示模板。
最后,该示例使用 Set-SPEnterpriseSearchResultItemType
cmdlet 修改结果项类型。
参数
-AssignmentCollection
管理对象以便正确进行处理。 使用 SPWeb 或 SPSite 等对象可能会耗用大量内存,而且在 Windows PowerShell 脚本中使用这些对象需要正确管理内存。 通过使用 SPAssignment 对象,可以将对象分配给变量,然后在不需要这些对象时对它们进行处理,以释放内存。 在使用 SPWeb、SPSite 或 SPSiteAdministration 对象时,如果不使用分配集合或 Global 参数,则会自动处理这些对象。
使用全局参数时,所有对象均包含在全局存储中。
如果未立即使用对象,或未通过使用 Stop-SPAssignment
命令来处理对象,则可能会发生内存不足的情况。
Type: | SPAssignmentCollection |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Applies to: | SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019 |
-Confirm
执行命令前,看到确认提示。
有关详细信息,请键入以下命令: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 2013, SharePoint Server 2016, SharePoint Server 2019 |
-DisplayProperties
指定要显示的结果属性。
Type: | String |
Aliases: | dp |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Applies to: | SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019 |
-DisplayTemplateUrl
指定应用于呈现结果的显示模板的 URL。
Type: | String |
Aliases: | url |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Applies to: | SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019 |
-Identity
指定要更新的结果项类型。 键入的值必须是 12345678-90ab-cdef-1234-567890bcdefgh 形式的有效 GUID。
Type: | ResultItemTypePipeBind |
Position: | 1 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Applies to: | SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019 |
-Name
指定结果项类型的名称。
Type: | String |
Aliases: | n |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Applies to: | SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019 |
-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 2013, SharePoint Server 2016, SharePoint Server 2019 |
-Owner
指定定义从中创建结果项类型的范围的搜索对象所有者。
Type: | SearchObjectOwner |
Aliases: | o |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Applies to: | SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019 |
-RulePriority
指定规则集合与其他规则相比所具有的优先级。
Type: | Int32 |
Aliases: | priority |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Applies to: | SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019 |
-Rules
指定要针对结果属性进行评估的规则集合。
Type: | PropertyRuleCollection |
Aliases: | rule |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Applies to: | SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019 |
-SearchApplication
指定搜索应用程序的名称。 键入的值必须是 12345678-90ab-cdef-1234-567890bcdefgh 形式的有效 GUID;有效的搜索应用程序名称(如 SearchApp1);或有效 SearchServiceApplication 对象的实例。
Type: | SearchServiceApplicationPipeBind |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Applies to: | SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019 |
-SearchApplicationProxy
指定包含结果项类型的搜索应用程序的代理。 键入的值必须是 12345678-90ab-cdef-1234-567890bcdefgh 形式的有效 GUID;有效的搜索应用程序代理名称(如 SearchAppProxy1);或有效 SearchServiceApplicationProxy 对象的实例。
Type: | SearchServiceApplicationProxyPipeBind |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Applies to: | SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019 |
-SourceID
标识结果项类型应用于的搜索结果源。
Type: | Guid |
Aliases: | sid |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Applies to: | SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019 |
-WhatIf
显示一条描述命令作用的消息,而不执行命令。
有关详细信息,请键入以下命令: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 2013, SharePoint Server 2016, SharePoint Server 2019 |