SharePoint Tips

Tuesday, January 16, 2018

SharePoint Search Query CollapseSpecification

Collapse similar search results using the CollapseSpecification property


The CollapseSpecification property takes a Spec parameter that can contain multiple fields separated either by a comma or a space, which evaluated together specify a set of criteria used for collapsing.

Syntax: CollapseSpecification = Spec

Table 1. Spec parameter fields
Element in parameterDescription
Spec Subspec(<space>Subspec)* 
Subspec Prop(','Prop)*[':'Dups] 
Prop A valid managed property or an alias of a managed property. Prop is case-insensitive. The managed property must be queryable and either sortable or refineable. 
Dups An integer specifying the number of items to retain. The default value is 1. 

Properties are combined by using the OR operator. 
, Properties are combined by using the AND operator. 
* Indicates more items. 
() or [] Indicates optional items. 
If the fields in Spec are separated by commas, the fields are combined by using the AND operator. If all of the specified fields are matched, the items are collapsed.
In contrast, if the fields in Spec are separated by spaces, the fields (or Subspecs) are combined by using an expansion that includes both the AND operator and ORoperator. For example, an expression such as Category:3 Product:2 is internally transformed to the following expression (Category AND Product) OR (Category) with a counter for each; hence a maximum of two of the former and three of the latter. Items are collapsed if some of the specified fields are matched.
Ref: https://docs.microsoft.com/en-us/sharepoint/dev/general-development/customizing-search-results-in-sharepoint

No comments:

Post a Comment