My data
{ "city":"New York", "street":"Atlantic Avenue" }
{ "city":"New York", "street":"Hudson Street" }
{ "city":"New York", "street":"Fawn Court" }
{ "city":"Boston", "street":"Atlantic Avenue" }
{ "city":"Boston", "street":"Hudson Street" }
{ "city":"Boston", "street":"7th Avenue" }
{ "city":"Washington DC", "street":"Atlantic Avenue" }
{ "city":"Washington DC", "street":"Dogwood Drive" }
{ "city":"Washington DC", "street":"7th Avenue" }
If we count each time that a street appears, we will get the following:
| Street name | Number of times |
|-----------------|-----------------|
| Atlantic Avenue | 3 |
| Hudson Street | 2 |
| 7th Avenue | 2 |
| Hudson Street | 1 |
| Dogwood Drive | 1 |
My goal
I want to build a histogram that says how many street names are unique, how many are seen twice, and so on...
To do so, I should get the result of a Terms Aggregation and send it to a Histogram Aggregation.
Here is the result for the example above:
| Street name count | Number of times |
|-------------------|-----------------|
| 1 | 2 |
| 2 | 2 |
| 3 | 1 |
What I have already done
I have build the first table with Kibana and this query:
curl -XGET 'http://localhost:9200/index1/type1/_search?pretty' -d '
{
"size": 0,
"aggs": {
"group_by_street": {
"terms": {
"field": "street"
}
}
}
}'
Then I tried to add this results to a histogram:
curl -XGET 'http://localhost:9200/fingerprint/user/_search?pretty' -d '
{
"size": 0,
"aggs": {
"histogram_streets": {
"histogram": {
"field": "group_by_street>_count",
"interval": 1
},
"aggs": {
"group_by_street": {
"terms": {
"field": "street"
}
}
}
}
}
}'
However, I retrieve an empty bucket.
Any idea of how can I do it?
Thanks!
group_by_street>_count
. What are you trying to do here? – Phil