# Elasticsearch-py: query a unique count

**URL:** <https://discuss.elastic.co/t/elasticsearch-py-query-a-unique-count/140957>\
**Category:** Elasticsearch\
**Created:** [July 20, 2018, 8:01pm UTC](https://discuss.elastic.co/t/elasticsearch-py-query-a-unique-count/140957 "2018-07-20T20:01:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mksavic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mksavic/32/32920_2.png) [@mksavic](https://discuss.elastic.co/u/mksavic)\
**Post date:** [July 20, 2018, 8:01pm UTC](https://discuss.elastic.co/t/elasticsearch-py-query-a-unique-count/140957/1 "2018-07-20T20:01:49Z")

</div>

Hello,

I am using elasticsearch-py for a project. Currently I have a filter that needs to be translated into python code.

```auto
system.process.name:my_process && system.process.cmdline:special_flag

```

In Kibana, I have this filter saved. I then use this filter in a visualization to perform a unique count on the `host` field for me.

I was wondering how I could convert this into an elasticsearch-py call.

So far I have

```auto
es.count(index='metricbeat', q='system.process.name:my_process && system.process.cmdline:special_flag')

```

But I still need that unique count of host.

---

<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:** [August 17, 2018, 8:03pm UTC](https://discuss.elastic.co/t/elasticsearch-py-query-a-unique-count/140957/2 "2018-08-17T20:03:54Z")

</div>

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