# How can I get the count of documents, clipped at a maximum by using only the Lucene query string?

**URL:** <https://discuss.elastic.co/t/how-can-i-get-the-count-of-documents-clipped-at-a-maximum-by-using-only-the-lucene-query-string/165003>\
**Category:** Elasticsearch\
**Created:** [January 21, 2019, 8:24am UTC](https://discuss.elastic.co/t/how-can-i-get-the-count-of-documents-clipped-at-a-maximum-by-using-only-the-lucene-query-string/165003 "2019-01-21T08:24:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michel\_Albert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michel_albert/32/18023_2.png) [@Michel\_Albert](https://discuss.elastic.co/u/Michel_Albert)\
**Post date:** [January 21, 2019, 8:24am UTC](https://discuss.elastic.co/t/how-can-i-get-the-count-of-documents-clipped-at-a-maximum-by-using-only-the-lucene-query-string/165003/1 "2019-01-21T08:24:33Z")

</div>

I am trying to graph the count of log-messages of several applications in a graph. But some applications send a log more logs than others. So the idea was to graph something like the following for each application (as SQL):

```
SELECT MAX(COUNT(*), 1) FROM log_messages;

```

This would give me either 1 or 0, depending if there are messages or not (which is exactly what we are looking for). This value could then be easily stacked in a graph. We use this in Grafana, and it seems that there is no way to combine the `max` and `count` functions in this manner.

Is there a way to do this?

---

<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:** [February 18, 2019, 8:24am UTC](https://discuss.elastic.co/t/how-can-i-get-the-count-of-documents-clipped-at-a-maximum-by-using-only-the-lucene-query-string/165003/2 "2019-02-18T08:24:43Z")

</div>

Closed on February 18, 2019, 8:24am UTC

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