Filter on a bulk of keywords

Hello community,

I have a simple question, I want to filter on a list of keywords, by creating an IF node and adding expression by expression will be time consuming, there is a way to add a bulk of exclusion keywords ?

Best,
Mahdi

Hey @TheG,

Quick way would be to use a code node and add all of your terms in an array and process the list that way.

@Jon Do you have a premade example to follow please ?

Hey @TheG,

I didn’t but I just popped this together, This will take a list of input names and if the name is not in the list it will pass them to the output.

1 Like

I’m curious @TheG if the following improvement to If node would solve your pain point:

  • New operation for string and number conditions called “Is one of” (or something like that)
  • You enter values separated by a comma in “Value 2” like “foo, bar, word3”
  • Condition is true if Value 1 matches any of those words

It’s an internal concept we have, so feedback on whether that would be helpful could help prioritize implementing it.

@maxT a feature like that which is easy to understand in the GUI would be nice, right now I use regex \b(foo|bar|word3)\b for cases like that.
But it would be a lot more readable, especially to colleagues without knowledge of regex, to have “Is one of” as an GUI option.

2 Likes

You can do this with an expression, by putting all your options in an array and using Javascript’s includes() function, like so:

{{ ['US', 'UK'].includes($json.country) }}

Example workflow:

1 Like

That will be definitly helpful and native, nevertheless the solution provided from @Jon worked smoothly.

2 Likes

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