How to take "average count on a field" as a metric?

My records look like this:

( uri, uniqid)

Each records represents one database visit in a specific request on the uri. For example:

(/home, 1)
(/home, 1)
(/home, 2)

means A request on /home , and visit twice on database. And another request on /home visit only once on database.

Now, I want to know which uri has the most visits on database in average.

So, the metrics is the average visit times , and the bucket is the uri.

I don't know how to get it done on kibana. Anyone can help?

This sounds like something we will be supporting once Elasticsearch 2.0 comes out. The current documentation for this unreleased feature here. Does it sound like what you are looking for?

Not actually.

For each uri, the score ( avg. DB visiting times) can be represented as :

count of (uri) / uniq count of (uri,  uniqid)

I want to sort on the score.