# From parameter in delete by query API

**URL:** https://discuss.elastic.co/t/from-parameter-in-delete-by-query-api/278636
**Category:** Elasticsearch
**Created:** [July 14, 2021, 10:02am UTC](https://discuss.elastic.co/t/from-parameter-in-delete-by-query-api/278636 "2021-07-14T10:02:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Sourav\_Patra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sourav_patra/32/79630_2.png) [@Sourav\_Patra](https://discuss.elastic.co/u/Sourav_Patra)
#### Post date: [July 14, 2021, 10:02am UTC](https://discuss.elastic.co/t/from-parameter-in-delete-by-query-api/278636/1 "2021-07-14T10:02:19Z")

</div>

I am trying to use the `[delete_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/7.x/docs-delete-by-query.html)` API to keep a maximum of 5 documents for a user that are most recent. I am using the sort parameter on a date field along with the `from` parameter. The from parameter is giving me the following error

```auto
Validation Failed: 1: using [from] is not allowed in a scroll context;
2: from is not supported in this context

```

I am using the following query -

```auto

POST http://<ip>/<index_name>/_delete_by_query
{
    "query": {
        "term": {
            "user": "12345"
        }
    },
    "sort": {
        "date": {
            "order": "desc"
        }
    },
    "from": 5
}

```

Could you help me identify what is causing the error? Do I need to change the scroll context to something else?

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: [August 11, 2021, 10:02am UTC](https://discuss.elastic.co/t/from-parameter-in-delete-by-query-api/278636/2 "2021-08-11T10:02:32Z")

</div>

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