New-SPEnterpriseSearchResultItemType
创建新的结果项类型。
语法
New-SPEnterpriseSearchResultItemType
[-Name] <String>
[-Rules] <PropertyRuleCollection>
[[-RulePriority] <Int32>]
[[-DisplayProperties] <String>]
[[-SourceID] <Guid>]
[-DisplayTemplateUrl] <String>
-Owner <SearchObjectOwner>
[-AssignmentCollection <SPAssignmentCollection>]
[-Confirm]
[-OptimizeForFrequentUse <Boolean>]
[-SearchApplication <SearchServiceApplicationPipeBind>]
[-SearchApplicationProxy <SearchServiceApplicationProxyPipeBind>]
[-WhatIf]
[<CommonParameters>]
New-SPEnterpriseSearchResultItemType
[[-Name] <String>]
[[-Rules] <PropertyRuleCollection>]
[[-RulePriority] <Int32>]
[[-DisplayProperties] <String>]
[[-SourceID] <Guid>]
[[-DisplayTemplateUrl] <String>]
-ExistingResultItemType <ResultItemTypePipeBind>
-ExistingResultItemTypeOwner <SearchObjectOwner>
-Owner <SearchObjectOwner>
[-AssignmentCollection <SPAssignmentCollection>]
[-Confirm]
[-OptimizeForFrequentUse <Boolean>]
[-SearchApplication <SearchServiceApplicationPipeBind>]
[-SearchApplicationProxy <SearchServiceApplicationProxyPipeBind>]
[-WhatIf]
[<CommonParameters>]
说明
使用 New-SPEnterpriseSearchResultItemType
cmdlet 创建新的结果项类型。
使用结果项类型,可以根据结果类型更改搜索结果的外观。 首先定义规则集合,这些规则将根据结果的属性进行评估。 然后定义用于呈现该类型结果的显示模板。 创建结果项类型后,与结果项类型规则匹配的结果将使用指定的显示模板呈现。
用例示例:
- 更改特定文件扩展名(例如 Word 文档)的结果外观。
- 更改搜索结果中特定内容类型的外观。
- 更改特定作者的结果的外观。
- 将一个结果操作从作为自定义搜索应用程序一部分的特定结果源添加到结果中。
有关适用于 SharePoint 产品的 Windows PowerShell 的权限和最新信息,请参阅 SharePoint Server cmdlet。
示例
------------------示例------------------
$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"
$web = Get-SPWeb https://webUrl
$tenantOwner = Get-SPEnterpriseSearchOwner -Level SPSite -SPWeb $web
$proxy = Get-SPEnterpriseSearchServiceApplicationProxy
New-SPEnterpriseSearchResultItemType -SearchApplicationProxy $proxy `
>> -Name "CustomResultType" `
>> -Rules $ruleCollection `
>> -RulePriority 1 `
>> -DisplayProperties $displayProperties `
>> -DisplayTemplateUrl $displaytemplateUrl `
>> -Owner $tenantOwner
此示例首先定义要应用于搜索结果的规则,以便以具有特定属性的结果为目标,并将规则添加到规则集合。
然后,它定义应显示的结果的属性以及用于控制所呈现结果的外观的显示模板的 URL。
最后,该示例通过名称、规则集合、显示属性、显示模板和租户所有者来定义规则项类型。
参数
-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: | 5 |
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。 指定绝对 URL。
Type: | String |
Aliases: | url |
Position: | 7 |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Applies to: | SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019 |
-ExistingResultItemType
指定可将新规则或显示的属性添加到的现有结果项类型。
Type: | ResultItemTypePipeBind |
Aliases: | copy |
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 |
-ExistingResultItemTypeOwner
指定用于定义从中创建结果项类型的范围的搜索对象所有者。
Type: | SearchObjectOwner |
Aliases: | eo |
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 |
-Name
指定结果项类型的名称。
Type: | String |
Aliases: | n |
Position: | 2 |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Applies to: | SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019 |
-OptimizeForFrequentUse
如果您始终希望请求此结果项类型的属性,则启用该标志,不管是否触发结果类型。 只要仅对最常用结果项类型启用该标志,则将提高性能。
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: | 4 |
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: | 3 |
Default value: | None |
Required: | True |
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: | True |
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: | 6 |
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 |