# Facet after distinct =\> facet after collapse

**URL:** <https://discuss.elastic.co/t/facet-after-distinct-facet-after-collapse/353564>\
**Category:** Elastic Search\
**Tags:** elastic-site-search\
**Created:** [February 19, 2024, 10:35am UTC](https://discuss.elastic.co/t/facet-after-distinct-facet-after-collapse/353564 "2024-02-19T10:35:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fvsadem](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fvsadem/32/131873_2.png) [@fvsadem](https://discuss.elastic.co/u/fvsadem)\
**Post date:** [February 19, 2024, 10:35am UTC](https://discuss.elastic.co/t/facet-after-distinct-facet-after-collapse/353564/1 "2024-02-19T10:35:53Z")

</div>

Hi,

I struggle to migrated from Algolia to Elasticsearch.  
My problem is facet after distinct option. I successfuly collapse my index to distinct by an attribute but there is a problem with the facets. The facets have the wrong number of items but when i count the result is good (collapse works)

There is my params that i use with the attribute for distinct "sku" :

```auto
{
  "query": {
    "match_all": {}
  },
  "collapse": {
    "field": "sku"
  },
  "aggs": {
    "skus_after_collapsing": {
      "terms": {
        "field": "sku.keyword"
      }
    },
    ...
    }
  }
}

```

My mapping for the filed "sku" :

```auto
"sku": {
    "type": "keyword"
},

```

Do someone have an idea ?

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 21, 2024, 1:48pm UTC](https://discuss.elastic.co/t/facet-after-distinct-facet-after-collapse/353564/3 "2024-03-21T13:48:11Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
