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

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
              }
            }
          }
        ]
      }
    },

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

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.

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

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.

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