# Can I use the information from the /\_segments REST call to find the total number of terms in an index?

**URL:** <https://discuss.elastic.co/t/can-i-use-the-information-from-the--segments-rest-call-to-find-the-total-number-of-terms-in-an-index/82059>\
**Category:** Elasticsearch\
**Created:** [April 11, 2017, 9:35pm UTC](https://discuss.elastic.co/t/can-i-use-the-information-from-the--segments-rest-call-to-find-the-total-number-of-terms-in-an-index/82059 "2017-04-11T21:35:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shadoninja](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@Shadoninja](https://discuss.elastic.co/u/Shadoninja)\
**Post date:** [April 11, 2017, 9:35pm UTC](https://discuss.elastic.co/t/can-i-use-the-information-from-the--segments-rest-call-to-find-the-total-number-of-terms-in-an-index/82059/1 "2017-04-11T21:35:09Z")

</div>

Here is the output for one of my indices when I hit the /\_segments REST API:

Will I be able to use this information to get the exact number of terms in an index?

```
"logs-2017-04-11": {
      "shards": {
        "0": [
          {
            "routing": {
              "state": "STARTED",
              "primary": true,
              "node": "_5ZLSvBOS1GKjWCCZKll3Q"
            },
            "num_committed_segments": 4,
            "num_search_segments": 1,
            "segments": {
              "_6e": {
                "generation": 230,
                "num_docs": 225,
                "deleted_docs": 0,
                "size_in_bytes": 195384,
                "memory_in_bytes": 0,
                "committed": true,
                "search": false,
                "version": "5.5.0",
                "compound": false
              },
              "_6f": {
                "generation": 231,
                "num_docs": 1,
                "deleted_docs": 0,
                "size_in_bytes": 14072,
                "memory_in_bytes": 0,
                "committed": true,
                "search": false,
                "version": "5.5.0",
                "compound": true
              },
              "_6g": {
                "generation": 232,
                "num_docs": 9,
                "deleted_docs": 0,
                "size_in_bytes": 29131,
                "memory_in_bytes": 0,
                "committed": true,
                "search": false,
                "version": "5.5.0",
                "compound": true
              },
              "_6h": {
                "generation": 233,
                "num_docs": 1,
                "deleted_docs": 0,
                "size_in_bytes": 15308,
                "memory_in_bytes": 0,
                "committed": true,
                "search": false,
                "version": "5.5.0",
                "compound": true
              },
              "_6j": {
                "generation": 235,
                "num_docs": 237,
                "deleted_docs": 0,
                "size_in_bytes": 208036,
                "memory_in_bytes": 25934,
                "committed": false,
                "search": true,
                "version": "5.5.0",
                "compound": false
              }
            }
          }
        ],
        "1": [
          {
            "routing": {
              "state": "STARTED",
              "primary": true,
              "node": "_5ZLSvBOS1GKjWCCZKll3Q"
            },
            "num_committed_segments": 2,
            "num_search_segments": 1,
            "segments": {
              "_64": {
                "generation": 220,
                "num_docs": 247,
                "deleted_docs": 0,
                "size_in_bytes": 216782,
                "memory_in_bytes": 0,
                "committed": true,
                "search": false,
                "version": "5.5.0",
                "compound": false
              },
              "_65": {
                "generation": 221,
                "num_docs": 1,
                "deleted_docs": 0,
                "size_in_bytes": 14232,
                "memory_in_bytes": 0,
                "committed": true,
                "search": false,
                "version": "5.5.0",
                "compound": true
              },
              "_69": {
                "generation": 225,
                "num_docs": 251,
                "deleted_docs": 0,
                "size_in_bytes": 220315,
                "memory_in_bytes": 25623,
                "committed": false,
                "search": true,
                "version": "5.5.0",
                "compound": false
              }
            }
          }
        ]
      }
    },
```

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 12, 2017, 3:17am UTC](https://discuss.elastic.co/t/can-i-use-the-information-from-the--segments-rest-call-to-find-the-total-number-of-terms-in-an-index/82059/2 "2017-04-12T03:17:43Z")

</div>

I don't believe there is any API that can provide this.

---

<div class="post-metadata">

**Author:** ![Shadoninja](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@Shadoninja](https://discuss.elastic.co/u/Shadoninja)\
**Post date:** [April 12, 2017, 3:39am UTC](https://discuss.elastic.co/t/can-i-use-the-information-from-the--segments-rest-call-to-find-the-total-number-of-terms-in-an-index/82059/3 "2017-04-12T03:39:35Z")

</div>

If there isn't anything simple, I think I can use the results of /\_segments to get a list of indices, then run the \_mapping call on each individual index to find the terms for that index. I don't like this solution, but I think it may work.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 12, 2017, 3:40am UTC](https://discuss.elastic.co/t/can-i-use-the-information-from-the--segments-rest-call-to-find-the-total-number-of-terms-in-an-index/82059/4 "2017-04-12T03:40:02Z")

</div>

What's driving the desire to have this level of info?

---

<div class="post-metadata">

**Author:** ![Shadoninja](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@Shadoninja](https://discuss.elastic.co/u/Shadoninja)\
**Post date:** [April 12, 2017, 3:57am UTC](https://discuss.elastic.co/t/can-i-use-the-information-from-the--segments-rest-call-to-find-the-total-number-of-terms-in-an-index/82059/5 "2017-04-12T03:57:01Z")

</div>

It is a stat that I have been tasked with getting. I am going to be feeding it to our stats service so we can monitor the shape of the ES db better. I don't know the direct value of getting this though.

---

<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:** [May 10, 2017, 4:04am UTC](https://discuss.elastic.co/t/can-i-use-the-information-from-the--segments-rest-call-to-find-the-total-number-of-terms-in-an-index/82059/6 "2017-05-10T04:04:37Z")

</div>

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