Ibexa DXP Discussions

Community discussion forum for developers working with Ibexa DXP

Look for duplicate / Group BY


I have a content type (Article) that has a text type “url” field (ezstring)

I’m looking for all articles that have the same url. (Search for duplicates.)

I imagined doing this with a GROUP BY, but I don’t see how to do it…

    $query->filter = new Query\Criterion\ContentTypeIdentifier('article');
    // $query->groupBy = new Query\GrouBy\Attribute('url'); // Does not exist
    // $query->sortClauses = [new Query\SortClause\GrouBy('url', 'desc')]; // Does not exist 
    $pager = new Pagerfanta(
        new ContentSearchAdapter($query, $this->searchService)

Ha. I have an idea I’ll see if I can’t do it with facets :slight_smile:

Yep, it’s definitely doable with Aggregation API in v3.2 (or facets in < 3.2, but you will need custom one). Let me know if you need any help :wink:

I am on 2.5 …

Got it :slight_smile:

    $query->facetBuilders[] =  new CustomFieldFacetBuilder([
            'name'     => 'url',
            'field'    => 'my_article_url_value_s',
            'minCount' => 2,
            'limit'    => null,
    $query->limit = 1;

CustomFieldFacetBuilder come from ezsolrsearchextrabundle

I had exactly the same idea :+1: Just in case of someone looking for v3.2 solution:

$aggregation =  new RawTermAggregation('url', 'my_article_url_value_s');

$query = new Query();
$query->limit = 0;
$query->aggregations[] = $aggregation;
1 Like