# Group Documents by it's similarity

**URL:** <https://discuss.elastic.co/t/group-documents-by-its-similarity/193446>\
**Category:** Elasticsearch\
**Created:** [August 2, 2019, 5:36am UTC](https://discuss.elastic.co/t/group-documents-by-its-similarity/193446 "2019-08-02T05:36:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yelji](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yelji/32/51486_2.png) [@yelji](https://discuss.elastic.co/u/yelji)\
**Post date:** [August 2, 2019, 5:36am UTC](https://discuss.elastic.co/t/group-documents-by-its-similarity/193446/1 "2019-08-02T05:36:04Z")

</div>

Hello,

I want to group the similar documents.

Here is sample documents

```
document 1 : {
 _id : 1,
message : "Have an adventurous and romantic valentines day this year"
}

document 2 : {
 _id : 2,
message : "Great ride with the car"
}

document 3 : {
 _id : 3,
message : "Had very romantic valentines day this year"
}

document 4 : {
 _id : 4,
message : "Night ride with my car was awesome"
}

```

from the above sample documents. I expect the output something like below one.

```
"aggregations": {
   "buckets": [
   {
       "key" : "Have an adventurous and romantic valentines day this year",
        doc_count": 2,
        "hits": [
             {
                 "id":1,
                 "message" : "Have an adventurous and romantic valentines day this year"
             } ,   
            {
                 "id":3,
                 "message" : "Had very romantic valentines day this year"
             } 
         ]
},
{
       "key" : "Great ride with the car",
        doc_count": 2,
        "hits": [
             {
                 "id":2,
                 "message" : "Great ride with the car"
             } ,   
            {
                 "id":4,
                 "message" : "Night ride with my car was awesome"
             } 
         ]
}
]
}
```

---

<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:** [August 30, 2019, 5:36am UTC](https://discuss.elastic.co/t/group-documents-by-its-similarity/193446/2 "2019-08-30T05:36:07Z")

</div>

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