Search for multiple values with == or exactly

Hi, anyone know a node that can search for multiple values exactly? Theres one that works but its contains, not ==

You can multicompare by using a cross product == comparison and checking the number of true results for each sublist. It looks like you have a structured list so you’ll want to check your levels along the way:

Thanks Robert, Ill give it a go. Just worried about cross lacing and speed. Going to end up with thousands of values and it can end up freezing for quite awhile

I can’t speak for big data optimization but you’re working with string comparisons at this point which are fairly light. Only recommendation I can offer is a pre-filter on your initial input list to keep the number of comparisons down, but that depends wholly on how you’re sourcing the input list.

1 Like

maybe theres a way to filter the original list by counting the words in it. Then that other node would work

Taking your initial screenshot as an example, your input list is functionally 6800 iterated twice, or 13600 comparisons. What you’re describing would look like (6800+[smallfilterx2]) comparisons. For this case example it wouldn’t be a significant improvement (or potentially any improvement), but that might change if you use this logic for more than 2 types.

@vanman You couple use a simple loop to see if list items exist in a search list.
Using this code is dependent on your list structures being exact, but there is scope to adjust to make it dynamic for any list structure.

# Simple Loop

lists = IN[0]
search = IN[1]
result = []

for li in lists:
    pack = []
    for l in li:
        if str(l) in search:
            pack.append(True)
        else:
            pack.append(False)
    result.append(pack)

OUT = result
2 Likes

Thanks Robert, your right. Only cross lacing x2 isnt to much, I’m so used to cross lacing for 2 big lists.

Thanks Ewan, simple and efficient with those awesome python skills as usual :slight_smile:

Managed to do with Roberts idea to filter the original list first too.

1 Like

Just FYI, you could also use List.AnyTrue here

1 Like

Get out of town. I shall be trying that later