# How to index my documents to aggregate similar item listings together

**URL:** <https://discuss.elastic.co/t/how-to-index-my-documents-to-aggregate-similar-item-listings-together/332342>\
**Category:** Elasticsearch\
**Created:** [May 2, 2023, 7:36pm UTC](https://discuss.elastic.co/t/how-to-index-my-documents-to-aggregate-similar-item-listings-together/332342 "2023-05-02T19:36:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![searchwithme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/searchwithme/32/137075_2.png) [@searchwithme](https://discuss.elastic.co/u/searchwithme)\
**Post date:** [May 2, 2023, 7:36pm UTC](https://discuss.elastic.co/t/how-to-index-my-documents-to-aggregate-similar-item-listings-together/332342/1 "2023-05-02T19:36:50Z")

</div>

Say I have a gaming website and there are panels that look like this:

## Panel A:

Game: Super Mario  
Language : English  
Number of Players: Two  
Theme: Nature

## Panel B:

Game:Super Mario  
Language : French  
Number of Players: Two  
Theme: Nature

Now, in my website instead of having two different panels like above, I want it as one with a dropdown that allows a user to browse between the different languages, instead of 2 panels.

Could you please let me know how I could restructure the indices so I can aggregate similar item listings together

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 3, 2023, 1:12am UTC](https://discuss.elastic.co/t/how-to-index-my-documents-to-aggregate-similar-item-listings-together/332342/2 "2023-05-03T01:12:33Z")

</div>

You should be able to do this with a query using collapse on the Game field - [Collapse search results | Elasticsearch Guide [8.7] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/8.7/collapse-search-results.html)

Otherwise you end up with a bit of a complex document as you will need nesting to manage the differences with the numeric fields you have.

---

<div class="post-metadata">

**Author:** ![searchwithme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/searchwithme/32/137075_2.png) [@searchwithme](https://discuss.elastic.co/u/searchwithme)\
**Post date:** [May 3, 2023, 4:20am UTC](https://discuss.elastic.co/t/how-to-index-my-documents-to-aggregate-similar-item-listings-together/332342/3 "2023-05-03T04:20:38Z")

</div>

Hi Warkolm,  
I can make the fields string. It doesn't have to be numeric. In that case, what changes could I make to my document? What type of nesting would work here?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 3, 2023, 8:22am UTC](https://discuss.elastic.co/t/how-to-index-my-documents-to-aggregate-similar-item-listings-together/332342/4 "2023-05-03T08:22:59Z")

</div>

I wouldn't use nesting as it can become complex, irrespective of if it's a string or a numeric. I would look to use collapse.

---

<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:** [May 31, 2023, 8:23am UTC](https://discuss.elastic.co/t/how-to-index-my-documents-to-aggregate-similar-item-listings-together/332342/5 "2023-05-31T08:23:26Z")

</div>

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