# Single Message Transform - Predicate & Filter

**URL:** <https://forum.confluent.io/t/single-message-transform-predicate-filter/4101>\
**Category:** Kafka Connect\
**Created:** [7 February 2022 14:24 UTC](https://forum.confluent.io/t/single-message-transform-predicate-filter/4101 "2022-02-07T14:24:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vnadkarni](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/vnadkarni/32/1839_2.png) [@vnadkarni](https://forum.confluent.io/u/vnadkarni)\
**Post date:** [7 February 2022 14:24 UTC](https://forum.confluent.io/t/single-message-transform-predicate-filter/4101/1 "2022-02-07T14:24:09Z")

</div>

_Conversation from Confluent Community Slack #connect channel. Copied here to make it available for others for reference._

**Anggara Aji Prasetya** :  
Hello, how to filter what mesage must be sinked to other database by field condition? Example: I want to sink topic employee to mysql only field “education” = “bachelor”.

**Neil Buesing @nbuesing** :  
Check out the apache connect single-message-transform (SMT), here is documentation from confluent

> **[Filter (Apache Kafka) | Confluent Documentation](https://docs.confluent.io/platform/current/connect/transforms/filter-ak.html)**
>
> This document provides usage information for the Apache Kafka Filter SMT org.apache.kafka.connect.transforms.Filter and how to use predicates.

**Anggara Aji Prasetya** :  
Thank you @nbuesing, I have an idea now how to do it 😃

**Robin Moffatt** :  
see also [🎄 Twelve Days of SMT 🎄 - Day 11: Predicate and Filter](https://rmoff.net/2020/12/22/twelve-days-of-smt-day-11-predicate-and-filter/)

**Anggara Aji Prasetya** :  
Yes, I got an idea when I see this video on youtube, thank you mr @rmoff

**Anggara Aji Prasetya** :  
I already did this SMT config  
Here is the config script

```auto
"transforms" : "filterPNM",
"transforms.filterPNM.type" : "io.confluent.connect.transforms.Filter$Value",
"transforms.filterPNM.filter.condition" : "$[?(@.email =~ /.PNM*/)]",
"transforms.filterPNM.filter.type" : "include"

```

I want to filter only message with value of email begin with word “PNM”  
the connector work well and I don’t have an error but it wonk sink to database, all of the message.  
Oh Btw, for source connector I used debezium for sql server. is that a problem ?"

**Anggara Aji Prasetya** :  
Oh I get it,  
I have a wrong condition in filter  
Instead of `/.PNM*/` the correct one is `/PNM.*/` and it’s worked 😃

**Neil Buesing** :  
@Anggara thanks for sharing your solution/outcome — this is what I love about the community — I have never done this specific SMT before, so nice to have another example to reference. If you haven’t shared this in the confluent forms, might be worth putting a post of it there (then it can be searched by others).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)\
**Post date:** [9 March 2022 14:24 UTC](https://forum.confluent.io/t/single-message-transform-predicate-filter/4101/2 "2022-03-09T14:24:32Z")

</div>

Closed on 9 March 2022 14:24 UTC

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