# Best way to do a top strings query?

**URL:** <https://discuss.elastic.co/t/best-way-to-do-a-top-strings-query/65913>\
**Category:** Elasticsearch\
**Created:** [November 13, 2016, 4:55pm UTC](https://discuss.elastic.co/t/best-way-to-do-a-top-strings-query/65913 "2016-11-13T16:55:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casieowen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/casieowen/32/8734_2.png) [@casieowen](https://discuss.elastic.co/u/casieowen)\
**Post date:** [November 13, 2016, 4:55pm UTC](https://discuss.elastic.co/t/best-way-to-do-a-top-strings-query/65913/1 "2016-11-13T16:55:34Z")

</div>

Hi,

We want to be able to do a "top strings" (that's my naming) query. Like a top terms, but want the top entire strings in a field rather than the terms. I followed the instructions in [this post](http://elasticsearch-users.115913.n3.nabble.com/Disabling-default-analyzer-td2932819.html) and reindexed the data with the field as not\_analyzed. After doing that, the query below does return the top strings:

GET indexname\*/\_search  
{  
"size": 0,  
"aggs": {  
"top-phrases-aggregation": {  
"terms": {  
"field":"contentAnalyzed",  
"size":20  
}  
}  
}  
}

So, I've got what I need, but I'm wondering if there are other/better ways to do this?

Thanks,  
Casie

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 13, 2016, 5:14pm UTC](https://discuss.elastic.co/t/best-way-to-do-a-top-strings-query/65913/2 "2016-11-13T17:14:57Z")

</div>

I don't believe so. Aggregation is the right way to go IMHO.

---

<div class="post-metadata">

**Author:** ![casieowen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/casieowen/32/8734_2.png) [@casieowen](https://discuss.elastic.co/u/casieowen)\
**Post date:** [November 13, 2016, 5:16pm UTC](https://discuss.elastic.co/t/best-way-to-do-a-top-strings-query/65913/3 "2016-11-13T17:16:39Z")

</div>

Thanks for the quick reply!

---

<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:** [December 11, 2016, 5:16pm UTC](https://discuss.elastic.co/t/best-way-to-do-a-top-strings-query/65913/4 "2016-12-11T17:16:48Z")

</div>

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