New-SPEnterpriseSearchResultItemType
Creates a new result item type.
Syntax
New
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>]
Copy
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
Use the New-SPEnterpriseSearchResultItemType
cmdlet to create a new result item type.
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
$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
This example first defines the rule to apply to the search results in order to target results with a specific property and adds the rule to the rule collection.
Thereafter the example defines the properties of the result that shall be displayed and the URL to the display template governing the appearance of the rendered results.
Finally, the example defines the rule item type by its name, the rule collection, the display properties, the display template and the tenant owner.
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 |
-DisplayProperties
Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019
Specifies which result properties to display.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | dp |
Parameter sets
(All)
Position: | 5 |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-DisplayTemplateUrl
Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019
Specifies the URL of the display template that shall be used for rendering the results. Specify an absolute URL.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | url |
Parameter sets
New
Position: | 7 |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
Copy
Position: | 7 |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-ExistingResultItemType
Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019
Specifies an existing result item type to which new rules or displayed properties can be added.
Parameter properties
Type: | ResultItemTypePipeBind |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | copy |
Parameter sets
Copy
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-ExistingResultItemTypeOwner
Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019
Specifies the search object owner that defines the scope at which an existing result item type was created.
Parameter properties
Type: | SearchObjectOwner |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | eo |
Parameter sets
Copy
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Name
Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019
Specifies the name of the result item type.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | n |
Parameter sets
New
Position: | 2 |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
Copy
Position: | 2 |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-OptimizeForFrequentUse
Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019
Enable this flag if you always want the properties of this result item type to be requested, regardless of whether the result type is triggered. This will improve performance as long as it is only enabled on the most frequently used result item types.
Parameter properties
Type: | Boolean |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | opt |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Owner
Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019
Specifies the search object owner that defines the scope at which the result item type is created.
Parameter properties
Type: | SearchObjectOwner |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | o |
Parameter sets
(All)
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-RulePriority
Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019
Specifies which priority the collection of rules has compared to other rules.
Parameter properties
Type: | Int32 |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | priority |
Parameter sets
(All)
Position: | 4 |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Rules
Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019
Specifies the collection of rules to evaluate the result properties against.
Parameter properties
Type: | PropertyRuleCollection |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | rule |
Parameter sets
New
Position: | 3 |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
Copy
Position: | 3 |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-SearchApplication
Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019
Specifies 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 name (for example, SearchApp1); or an instance of a valid SearchServiceApplication object.
Parameter properties
Type: | SearchServiceApplicationPipeBind |
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 |
-SearchApplicationProxy
Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019
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.
Parameter properties
Type: | SearchServiceApplicationProxyPipeBind |
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 |
-SourceID
Applicable: SharePoint Server 2013, SharePoint Server 2016, SharePoint Server 2019
Identifies the search result source that the result item type applies to. Leave this parameter blank to apply to all result sources.
Parameter properties
Type: | Guid |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | sid |
Parameter sets
(All)
Position: | 6 |
Mandatory: | False |
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.