# Fetch records with Group by with Completion Suggester

**URL:** <https://discuss.elastic.co/t/fetch-records-with-group-by-with-completion-suggester/211278>\
**Category:** Elasticsearch\
**Created:** [December 10, 2019, 10:49am UTC](https://discuss.elastic.co/t/fetch-records-with-group-by-with-completion-suggester/211278 "2019-12-10T10:49:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishal\_chauhan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vishal_chauhan/32/59108_2.png) [@vishal\_chauhan](https://discuss.elastic.co/u/vishal_chauhan)\
**Post date:** [December 10, 2019, 10:49am UTC](https://discuss.elastic.co/t/fetch-records-with-group-by-with-completion-suggester/211278/1 "2019-12-10T10:49:49Z")

</div>

{  
"XYZ": {  
"mappings": {  
"properties": {  
"customerInfo": {  
"properties": {  
"emailList": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword"  
}  
}  
},  
"id": {  
"type": "text",  
"fields": {  
"completion": {  
"type": "completion",  
"analyzer": "standard",  
"preserve\_separators": true,  
"preserve\_position\_increments": true,  
"max\_input\_length": 50,  
"contexts": [  
{  
"name": "mailboxIdStr",  
"type": "CATEGORY",  
"path": "mailboxIdStr"  
}  
]  
},  
"keyword": {  
"type": "keyword"  
}  
}  
},  
"name": {  
"type": "text",  
"fields": {  
"completion": {  
"type": "completion",  
"analyzer": "simple",  
"preserve\_separators": true,  
"preserve\_position\_increments": true,  
"max\_input\_length": 50,  
"contexts": [  
{  
"name": "mailboxIdStr",  
"type": "CATEGORY",  
"path": "mailboxIdStr"  
}  
]  
},  
"keyword": {  
"type": "keyword"  
}  
},  
"fielddata": true  
}  
}  
}  
}  
}  
}  
}

I need customer name group by customerid as per below.

```
Name customerid
John 1	
John 2
John12 3
```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 10, 2019, 12:36pm UTC](https://discuss.elastic.co/t/fetch-records-with-group-by-with-completion-suggester/211278/2 "2019-12-10T12:36:47Z")

</div>

Instead of only pasting snippets, how about you start a little bit earlier by giving a bit of context, coming up with a problem statement, how far you got, what you expected to work and how the actual result differs.

Writing a good problem description is hard work, but will help to get your issue solved or just looked at. See also [https://www.elastic.co/help](https://www.elastic.co/help)

Thanks!

---

<div class="post-metadata">

**Author:** ![vishal\_chauhan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vishal_chauhan/32/59108_2.png) [@vishal\_chauhan](https://discuss.elastic.co/u/vishal_chauhan)\
**Post date:** [December 11, 2019, 9:59am UTC](https://discuss.elastic.co/t/fetch-records-with-group-by-with-completion-suggester/211278/3 "2019-12-11T09:59:43Z")

</div>

I have put my code on PASTEBIN with description what i'm doing and what response i get.

Link: [https://pastebin.com/6gcaXZGz](https://pastebin.com/6gcaXZGz)

---

<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:** [January 8, 2020, 9:59am UTC](https://discuss.elastic.co/t/fetch-records-with-group-by-with-completion-suggester/211278/4 "2020-01-08T09:59:44Z")

</div>

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