If you index your product catalog by SKU, each result returned from a query represents an individual SKU. This means some products may appear multiple times, because the query may match multiple SKUs for an individual product.
If you want to return each product only once, you can group the results by product ID. Oracle ATG Web Commerce Search will return a single result for each unique product ID.
To enable grouping, you set the sorting
property of the QueryRequest
component to property
(to enable grouping by property), and set the sortProperty
to the index property to group by. For example:
sorting=property
sortProperty=string:$repositoryId:1
Note that in spite of their names, these QueryRequest
properties control grouping, not sorting.
The format for the value of sortProperty
is:
data-type
:index-pr
operty
:default-value
In the example above, the property is $repositoryId
, which means the repository ID of the top-level item type in the IndexingOutputConfig
definition file. The top-level item type is the product item, so the product ID is used as the grouping property. If a product ID value cannot be found for an item in the index, the default value (in this example, 1) is used for that item instead.
If you are using faceted search, you should also set the refineCount
property to group
, so the refinement counts reflect the number of products in each facet selection, rather than the number of SKUs:
refineCount=group
For more information about refinement counts in faceted search, see About Refinement Counts.