New-SPEnterpriseSearchResultItemType
建立新的結果項目類型。
Syntax
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>]
Description
使用 Cmdlet New-SPEnterpriseSearchResultItemType
建立新的結果專案類型。
結果項目類型可讓您根據結果類型變更搜尋結果的外觀。 首先您要定義規則集合 (將會比對結果屬性來評估此規則集合)。 然後您要定義用來呈現結果類型的顯示範本。 建立結果項目類型之後,符合結果項目類型規則的結果就會使用指定的顯示範本來呈現。
使用範例:
- 變更特定副檔名的結果外觀,例如 Word 文件。
- 變更搜尋結果中,特定內容類型的外觀。
- 變更特定作者的結果外觀。
- 將結果動作新增至特定結果來源中的結果,以做為自訂搜尋應用程式的一部分。
如需適用於 SharePoint 產品的 Windows PowerShell 權限及最新資訊,請參閱位於 SharePoint Server Cmdlets 的線上文件。
範例
------------------範例------------------
$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 參數,將會自動處置這些物件。
使用 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
指定包含結果項目類型的搜尋應用程式 Proxy。 此類型必須是格式為 12345678-90ab-cdef-1234-567890bcdefgh 的有效 GUID;有效的搜尋應用程式 Proxy 名稱 (例如 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 |