# Getting /Visualizing the frequency distribution of the scores of all the matching documents

**URL:** <https://discuss.elastic.co/t/getting-visualizing-the-frequency-distribution-of-the-scores-of-all-the-matching-documents/87535>\
**Category:** Elasticsearch\
**Created:** [May 30, 2017, 9:20am UTC](https://discuss.elastic.co/t/getting-visualizing-the-frequency-distribution-of-the-scores-of-all-the-matching-documents/87535 "2017-05-30T09:20:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nicom/32/488_2.png) [@nicom](https://discuss.elastic.co/u/nicom)\
**Post date:** [May 30, 2017, 9:20am UTC](https://discuss.elastic.co/t/getting-visualizing-the-frequency-distribution-of-the-scores-of-all-the-matching-documents/87535/1 "2017-05-30T09:20:22Z")

</div>

Hi

I would like to display the frequency distribution of the scores of all the matching documents from a query.

for instance if I execute the query A, I would like to get a frequency distribution like:

- 10 documents have a score between [0 - 10]
- 20 documents have a score between [11 - 20]
- 5 documents have a score between [21 - 30]

=\> How to post aggregate the resulting scores of the matching documents of a query ?

Thanks !

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [May 30, 2017, 12:29pm UTC](https://discuss.elastic.co/t/getting-visualizing-the-frequency-distribution-of-the-scores-of-all-the-matching-documents/87535/2 "2017-05-30T12:29:26Z")

</div>

Try this:

```
GET /my_index/_search
{
  "query": {
	"query_string": {
	  "query": "myquery"
	}
  },
  "aggs": {
	"score_ranges": {
	  "histogram": {
		"script":{
		  "inline":"_score"
		},
		"interval": 10
	  }
	}
  }
}
```

---

<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:** [June 27, 2017, 12:29pm UTC](https://discuss.elastic.co/t/getting-visualizing-the-frequency-distribution-of-the-scores-of-all-the-matching-documents/87535/3 "2017-06-27T12:29:49Z")

</div>

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