Reputation: 998
Hi i have tried to perform a search operation on my data using Apache pig. My code is like below
data = load 'sample.txt' using PigStorage(',') as (id:chararray, fname:chararray, lname:chararray);
C = filter data by fname matches '.*Ma.*';
D = foreach C generate construction;
dump D;
Here i am able to find the data on either fname or lname. But i want to perform the search on both the columns.
I tried like below 1) applied the filter on data by adding the search condition on fname.
2) applied the filter on data by adding the search condition on lname
3) Union both the search result;
Is this the right way or any other good suggestions please.
Upvotes: 0
Views: 389
Reputation: 2287
Use OR and perform the search in a single FILTER
C = filter data by fname matches '.*Ma.*' OR lname matches '.*Ma.*';
Upvotes: 1