# Excluding max value from Data table

**URL:** <https://discuss.elastic.co/t/excluding-max-value-from-data-table/184074>\
**Category:** Kibana\
**Created:** [June 4, 2019, 1:43am UTC](https://discuss.elastic.co/t/excluding-max-value-from-data-table/184074 "2019-06-04T01:43:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AditiKhalatkar](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@AditiKhalatkar](https://discuss.elastic.co/u/AditiKhalatkar)\
**Post date:** [June 4, 2019, 1:43am UTC](https://discuss.elastic.co/t/excluding-max-value-from-data-table/184074/1 "2019-06-04T01:43:26Z")

</div>

Hi,

I am trying to achieve a result set where if there are 10 records, I want only 9 of them. Excluding the one which has maximum id.

For instance, there are 4 docs in my index.

```
{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 4,
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "rank",
        "_type" : "data",
        "_id" : "2",
        "_score" : 1.0,
        "_source" : {
          "id" : 2,
          "name" : "Rank2"
        }
      },
      {
        "_index" : "rank",
        "_type" : "data",
        "_id" : "4",
        "_score" : 1.0,
        "_source" : {
          "id" : 4,
          "name" : "Rank4"
        }
      },
      {
        "_index" : "rank",
        "_type" : "data",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "id" : 1,
          "name" : "Rank1"
        }
      },
      {
        "_index" : "rank",
        "_type" : "data",
        "_id" : "3",
        "_score" : 1.0,
        "_source" : {
          "id" : 3,
          "name" : "Rank3"
        }
      }
    ]
  }
}

```

Mapping as

```
{
  "rank" : {
    "mappings" : {
      "data" : {
        "properties" : {
          "id" : {
            "type" : "long"
          },
          "name" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          }
        }
      }
    }
  }
}

```

I want to fetch only last 3 records.

A query something like

```
GET rank/_search
{
  "from":1,
  "query":{
    "match_all": {}
  },
  "sort": [
    {
      "id": {
        "order": "desc"
      }
    }
  ]
}

```

Since I am using from:1, it would exclude id:4. I needed the same results in Kibana Data Table. Kindly guide how should I proceed.

Thanks.

---

<div class="post-metadata">

**Author:** ![clintandrewhall](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/clintandrewhall/32/45435_2.png) [@clintandrewhall](https://discuss.elastic.co/u/clintandrewhall)\
**Post date:** [June 5, 2019, 5:16pm UTC](https://discuss.elastic.co/t/excluding-max-value-from-data-table/184074/2 "2019-06-05T17:16:46Z")

</div>

Good day, Aditi! Does the `size` query parameter help?

[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html)

---

<div class="post-metadata">

**Author:** ![AditiKhalatkar](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@AditiKhalatkar](https://discuss.elastic.co/u/AditiKhalatkar)\
**Post date:** [June 5, 2019, 5:20pm UTC](https://discuss.elastic.co/t/excluding-max-value-from-data-table/184074/3 "2019-06-05T17:20:18Z")

</div>

Hello

Good day to you too 🙂

Not sure if I can use the size parameter since I may not know the maximum number of fields.

For instance, there can be 30 ids, 35 ids and the index may grow. I need a 29ids in my table(30-1) or if the index gets updated with 35 ids, then 34ids. If there is a way to set the "from" parameter in table, it might be helpful.

---

<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:** [July 3, 2019, 5:20pm UTC](https://discuss.elastic.co/t/excluding-max-value-from-data-table/184074/4 "2019-07-03T17:20:27Z")

</div>

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