Skip to content

Projections: Duplicated results with random sorting when multiple terms are selected in a content item #8732

@AndreaPiovanelli

Description

@AndreaPiovanelli

https://github.com/OrchardCMS/Orchard/blob/03884cbd6431721ffe69b03c69ba672a1cb44dc1/src/Orchard.Web/Modules/Orchard.Projections/Services/ProjectionManager.cs#L155C2-L155C2

When applying a filter on the terms of a taxonomy, results are sometimes duplicated; this happens when a terms filter (HasTerms) is applied (in combination to other filters, e.g. a filter on content types) and a content item matches the filter for more than one term: in this situation, the resulting contentItems list contains multiple occurences of the same content item (specifically, one occurence for each term matching the filter).

Patch has to be applied here in ProjectionManager instead of Orchard.Taxonomies.Projections.TermsFilter.ApplyFilter function because, in the latter, query is not executed yet and, for this reason, duplicate content items cannot be removed.

Edit: after more digging, the issue is caused by the "random sorting", which disables the "select distinct" clause inside the "DefaultHqlQuery.ToHql" function called by the "HqlQuery.Slice" function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions