# Suggestion for filtering based on multiple predicate

**URL:** <https://discuss.aerospike.com/t/suggestion-for-filtering-based-on-multiple-predicate/8344>\
**Category:** Node.js Client\
**Tags:** query, udf, predicate, nodejs\
**Created:** [March 29, 2021, 4:48pm UTC](https://discuss.aerospike.com/t/suggestion-for-filtering-based-on-multiple-predicate/8344 "2021-03-29T16:48:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aditya\_Gupta](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/aditya_gupta/32/1628_2.png) [@Aditya\_Gupta](https://discuss.aerospike.com/u/Aditya_Gupta)\
**Post date:** [March 29, 2021, 4:48pm UTC](https://discuss.aerospike.com/t/suggestion-for-filtering-based-on-multiple-predicate/8344/1 "2021-03-29T16:48:53Z")

</div>

I have been through several forum discussions and found that there is limited support for querying Aerospike with multiple predicates.  
One solution is to use UDFs to further filter out the resuts. Like in [this post](https://discuss.aerospike.com/t/multiple-filters-query-problem/2419/4).

I have a data which contains Date, Integer, and String fields.  
Is it possible for me to filter records using all the following predicates together:

- Equality on String fields
- Range query on Integer field.
- Range query on Date fields

If so, how can I do so. I am ok with UDF logic too if that’s the only possible solution.

---

<div class="post-metadata">

**Author:** ![Aditya\_Gupta](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/aditya_gupta/32/1628_2.png) [@Aditya\_Gupta](https://discuss.aerospike.com/u/Aditya_Gupta)\
**Post date:** [March 29, 2021, 4:49pm UTC](https://discuss.aerospike.com/t/suggestion-for-filtering-based-on-multiple-predicate/8344/2 "2021-03-29T16:49:22Z")

</div>

@pisush Could you please help me with this. Thanks.

---

<div class="post-metadata">

**Author:** ![Aditya\_Gupta](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/aditya_gupta/32/1628_2.png) [@Aditya\_Gupta](https://discuss.aerospike.com/u/Aditya_Gupta)\
**Post date:** [March 29, 2021, 5:21pm UTC](https://discuss.aerospike.com/t/suggestion-for-filtering-based-on-multiple-predicate/8344/3 "2021-03-29T17:21:20Z")

</div>

Here, I was able to use [predexp](https://www.aerospike.com/apidocs/nodejs/module-aerospike_predexp.html) to filter on 2 fields, but date range filtering is still a mystery to me.

Perhaps I have to convert my dates to Unix timestamps.

---

<div class="post-metadata">

**Author:** ![pisush](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/pisush/32/1385_2.png) [@pisush](https://discuss.aerospike.com/u/pisush)\
**Post date:** [April 14, 2021, 1:27pm UTC](https://discuss.aerospike.com/t/suggestion-for-filtering-based-on-multiple-predicate/8344/4 "2021-04-14T13:27:44Z")

</div>

Hey Aditya,

Record last update time can be included in the predicate expressions. Here’s a good read about it:

> **[Dealing with Predicate Expression Filters in Aerospike REST Client (Part 2)](https://dev.to/aerospike/dealing-with-predicate-expression-filters-in-aerospike-rest-client-part-2-58m9)**
>
> In the previous part we spoke about using simple Predicate Expression Filters with the Aerospike RE...

And here’s another example of using predicate filters using just a time range:

> **[The Power of Aerospike Predicate Filters](https://medium.com/aerospike-developer-blog/the-power-of-aerospike-predicate-filters-79c9160469bd)**
>
> Why use Predicates?

**Important note:** As of Aerospike Database 5.2, Predicate Expressions (PredExps) are obsolete. Please use [Aerospike Expressions](https://www.aerospike.com/docs/guide/expressions) instead. The Aerospike Server and Client will support both Predicate Expressions (PredExps) and Aerospike Expressions until November 2021. From November 2021 support for Predicate Expressions will be removed from both Aerospike server and clients. (From [https://www.aerospike.com/docs/guide/predicate.html](https://www.aerospike.com/docs/guide/predicate.html))

Cheers
