# Showing in "total" only one per transactionId

**URL:** <https://discuss.elastic.co/t/showing-in-total-only-one-per-transactionid/102523>\
**Category:** Elasticsearch\
**Created:** [October 3, 2017, 7:44am UTC](https://discuss.elastic.co/t/showing-in-total-only-one-per-transactionid/102523 "2017-10-03T07:44:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomer](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@tomer](https://discuss.elastic.co/u/tomer)\
**Post date:** [October 3, 2017, 7:44am UTC](https://discuss.elastic.co/t/showing-in-total-only-one-per-transactionid/102523/1 "2017-10-03T07:44:14Z")

</div>

Hi,

I am trying to ask how many transactions have a delay greater than 3. The problem is that in one transaction there are more than one log with a the same delay value. Therefore for an example if there is only one transaction and it has a delay of 4 it might have 2 logs of that contains delay = 3. How can I get that the query will give in the value of total 1 and not 2.

Here is my query:

```
{
    "size": 100,
   "query": {
    
   "bool":{ 

      "must": [
        { "range": 
          { 
            "delay": 
              {
                "gte": 3
              } 
          }
        }
      ]
   }
  },
  "aggs": {
        "group": {
            "terms": {
                "field": "transactionId"
            }
		}
   }
}

```

PS  
the field that unites all logs of a transactionId is called "transactionId"

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 3, 2017, 7:57am UTC](https://discuss.elastic.co/t/showing-in-total-only-one-per-transactionid/102523/2 "2017-10-03T07:57:19Z")

</div>

Have you tried using a [cardinality aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-aggregations-metrics-cardinality-aggregation.html) on the `transactionId`?

---

<div class="post-metadata">

**Author:** ![tomer](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@tomer](https://discuss.elastic.co/u/tomer)\
**Post date:** [October 3, 2017, 8:03am UTC](https://discuss.elastic.co/t/showing-in-total-only-one-per-transactionid/102523/3 "2017-10-03T08:03:39Z")

</div>

Hi,

Thanks for the fast reply!

Yes, here is an example:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/8/e88bb6301ddb4722686c1563b28ac9ab16b6f4ec.png)

This should've returned me only one, no?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 3, 2017, 8:05am UTC](https://discuss.elastic.co/t/showing-in-total-only-one-per-transactionid/102523/4 "2017-10-03T08:05:31Z")

</div>

No, documents returned will depend on what matches the query. The result from the cardinality aggregation should show 1.

---

<div class="post-metadata">

**Author:** ![tomer](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@tomer](https://discuss.elastic.co/u/tomer)\
**Post date:** [October 3, 2017, 8:24am UTC](https://discuss.elastic.co/t/showing-in-total-only-one-per-transactionid/102523/6 "2017-10-03T08:24:14Z")

</div>

Yes I looked in the wrong place thanks

---

<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:** [October 31, 2017, 8:28am UTC](https://discuss.elastic.co/t/showing-in-total-only-one-per-transactionid/102523/7 "2017-10-31T08:28:53Z")

</div>

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