# How to delete multiple records on the bases of secondary index

**URL:** <https://discuss.aerospike.com/t/how-to-delete-multiple-records-on-the-bases-of-secondary-index/3465>\
**Category:** Deletion\
**Tags:** deletion\
**Created:** [October 1, 2016, 3:36am UTC](https://discuss.aerospike.com/t/how-to-delete-multiple-records-on-the-bases-of-secondary-index/3465 "2016-10-01T03:36:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anuj\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@Anuj\_Gupta](https://discuss.aerospike.com/u/Anuj_Gupta)\
**Post date:** [October 1, 2016, 3:36am UTC](https://discuss.aerospike.com/t/how-to-delete-multiple-records-on-the-bases-of-secondary-index/3465/1 "2016-10-01T03:36:46Z")

</div>

how to delete multiple records on the bases of secondary index

---

<div class="post-metadata">

**Author:** ![rbotzer](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/rbotzer/32/2114_2.png) [@rbotzer](https://discuss.aerospike.com/u/rbotzer)\
**Post date:** [October 1, 2016, 4:05am UTC](https://discuss.aerospike.com/t/how-to-delete-multiple-records-on-the-bases-of-secondary-index/3465/2 "2016-10-01T04:05:15Z")

</div>

You’d attach a [record UDF](http://www.aerospike.com/docs/guide/record_udf.html) to the query, such that the lua function is called on every record matched by the predicate.

In the Python client you’d do so using [`aerospike.Client.query_apply`](http://www.aerospike.com/apidocs/python/client.html#aerospike.Client.query_apply). The UDF function would be something like:

```nohighlight
function del_rec(rec)
  aerospike:remove(rec)
end

```
