Let us discuss about How to implement Like operations in Pentaho.
Here, I have designed the transformation to handle like operation which is same as like clause in database. See the below Transformation design.
![](https://www.allabouttechnologies.co.in/wp-content/uploads/2020/11/image-1024x273.png)
See the values in the Generate rows components.
See the code written in Modified JavaScript Value Component.
Here if you see I have used function “getOcuranceString” which will give value in terms of number of occurrences of a substring in the main string. In other words, we can say if it returns value 0 that means value which is “123” in this code is not present in the string and if it returns value greater than equal to 1 then it is present.
Here , I have set flg to 1 if it is present else set to 0. Below is the code .if (getOcuranceString(fld1, "123")>=1)
{
var flg=1
var occr=getOcuranceString(fld1, "123")
}
else
{
var flg=0
var occr=getOcuranceString(fld1, "123")
}
See the logs component
In write to logs component, I am printing flg and occr fields .
See the output logs of transformation execution.
Write to log.0 –
Write to log.0 – ————> Linenr 1——————————
Write to log.0 – flg = 1
Write to log.0 – occr = 2
Write to log.0 –
Write to log.0 – ====================
Write to log.0 –
Write to log.0 – ————> Linenr 2——————————
Write to log.0 – flg = 1
Write to log.0 – occr = 1
Write to log.0 –
Write to log.0 – ====================
Therefore, based on flg field value , you can design your remaining ETL code.