Searching through all columns at a time

Hi,
Is there any way to use the filter function to apply a condition to all columns at a time other than specifically calling a column or number of columns.
For example I want to search a keyword in all columns using regex. So is it possible?

Hello @Vidhya,
Yes you can use filters to do conditional filtering:

Yes you can also use regex

1 Like

Hi @Anaisdg ,
Thank you for your reply. But I am afraid to say that this is not the answer I am looking for. May be I will rephrase my question so that you can understand my problem.
So I want to search for some keywords in entire database not on subset of columns. To look for keywords on one column I can use the filter function with regex , But if I want to search through all the columns at the same time how can I construct the function?
eg:
To search for the keyword “mem” in the column “_measurement” I can write :

|> filter(fn: (r) => r._measurement  =~ /.*mem.*/ )

So then what would be the solution if I want to search for the word “mem” in all columns at the same time ?

Thank you,
Vidhya

Hello @Vidhya,
You’d have to do something like:

|> filter(fn: (r) => r._column_1  =~ /.*mem.*/ or r._column_2  =~ /.*mem.*/ or r._column_3 =~ /.*mem.*/...)

You can also use contains:

import "influxdata/influxdb/sample"

fields = ["temperature", "humidity"]

sample.data(set: "airSensor")
    |> range(start: -30m)
    |> filter(fn: (r) => contains(value: r._field, set: fields))

Hi @Anaisdg,

Thank you for your reply!
I think the contains function is helpful but in my case I want to apply the contains function in every column present in the database not on a specified set of columns. So is there any way to define the set of fields as all columns?

Thanks!
Vidhya