# Possible to do a histogram of terms aggs without the terms?

**URL:** <https://discuss.elastic.co/t/possible-to-do-a-histogram-of-terms-aggs-without-the-terms/57706>\
**Category:** Elasticsearch\
**Created:** [August 10, 2016, 1:07pm UTC](https://discuss.elastic.co/t/possible-to-do-a-histogram-of-terms-aggs-without-the-terms/57706 "2016-08-10T13:07:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yehosef](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yehosef/32/42175_2.png) [@yehosef](https://discuss.elastic.co/u/yehosef)\
**Post date:** [August 10, 2016, 1:07pm UTC](https://discuss.elastic.co/t/possible-to-do-a-histogram-of-terms-aggs-without-the-terms/57706/1 "2016-08-10T13:07:28Z")

</div>

We have report of page link interlinking where each document contains a source link and target link. We want to find how many documents have 1 link vs how many have 2 vs 3 etc.

Normally I'd approach this as a terms aggs at the source link - this link has 2 docs, this has 5, etc. But we have maybe a million links and I don't think a terms aggs would be a good idea. And on top of that, we really just what the number that have this many links, we don't care about the actual links.

How could I do this in Elasticsearch?

---

<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:** [August 12, 2016, 4:34am UTC](https://discuss.elastic.co/t/possible-to-do-a-histogram-of-terms-aggs-without-the-terms/57706/2 "2016-08-12T04:34:51Z")

</div>

You could do that with Graph pretty simply, but you may run into the same problems at that large scale. It'd certainly be hard to show the relationships with so many links.

---

<div class="post-metadata">

**Author:** ![yehosef](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yehosef/32/42175_2.png) [@yehosef](https://discuss.elastic.co/u/yehosef)\
**Post date:** [August 15, 2016, 7:37am UTC](https://discuss.elastic.co/t/possible-to-do-a-histogram-of-terms-aggs-without-the-terms/57706/3 "2016-08-15T07:37:05Z")

</div>

Thanks for the reply. I don't think I need the actual terms, just the histogram of the number of terms that have the number of documents.

For example, if I have 1 million urls that are each intern-linked to 10 other urls. I have documents which have the source\_url and the target\_url. I want to know how many target\_urls have 1 link in (source\_url), how many have 2, etc. I don't care what the urls are or how they are linked, just the histogram of numbers. If the documents are perfectly interconnected, I might have 10M documents with 10 connections. More realistically, there will be many with 1 link and many with 50 links.. I need to know how many.

Perhaps this could be done with a pipeline aggregation - the issue is that it seems I usually need to also return the primary aggregation results and that would be a lot of documents (1 M) .

---

<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:** [July 5, 2017, 10:27pm UTC](https://discuss.elastic.co/t/possible-to-do-a-histogram-of-terms-aggs-without-the-terms/57706/4 "2017-07-05T22:27:49Z")

</div>


