# Searching through an array

**URL:** <https://discourse.nodered.org/t/searching-through-an-array/16828>\
**Category:** General\
**Created:** [17 October 2019 19:02 UTC](https://discourse.nodered.org/t/searching-through-an-array/16828 "2019-10-17T19:02:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joepierce88](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@joepierce88](https://discourse.nodered.org/u/joepierce88)\
**Post date:** [17 October 2019 19:02 UTC](https://discourse.nodered.org/t/searching-through-an-array/16828/1 "2019-10-17T19:02:35Z")

</div>

Hi all, I've done some searching through the forum and I can't seem to figure this out. I'm sending an email message to IBM Watson classifier. It is returning an array object with each sentence individually classified. I'm looking to see if any of the top\_class match a particular string so I need to search through the array with a switch variable in order to initiate different workflows based on existing classifications.

I tried splitting the message, converting it to another type, and I can't seem to find how to get string values in an array to trigger the proper switch.

Thanks,  
Joe

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [17 October 2019 19:23 UTC](https://discourse.nodered.org/t/searching-through-an-array/16828/2 "2019-10-17T19:23:32Z")

</div>

It is much easier to help you if you post an example of the message

---

<div class="post-metadata">

**Author:** ![joepierce88](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@joepierce88](https://discourse.nodered.org/u/joepierce88)\
**Post date:** [17 October 2019 19:26 UTC](https://discourse.nodered.org/t/searching-through-an-array/16828/3 "2019-10-17T19:26:52Z")

</div>

At the end of this message is the email I'm checking:

The idea is to have classifier identify if any of these are an adverse event or request for information. I send it to the classifier and the results come back into a collection array, properly identifying the top\_class of Adverse\_Event for the 3rd sentence. The intent of Adverse Event could be anywhere in the message so if there is a top\_class of Adverse\_Event identified anywhere, I need the switch to send the message to an email for notification.

"I was going to the store. I fell and needed to take some medicine. After I took the aspirin I got a rash.

Thanks,

Joe Pierce"

---

<div class="post-metadata">

**Author:** ![3amWednesday](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/3amwednesday/32/10371_2.png) [@3amWednesday](https://discourse.nodered.org/u/3amWednesday)\
**Post date:** [24 October 2019 10:34 UTC](https://discourse.nodered.org/t/searching-through-an-array/16828/4 "2019-10-24T10:34:22Z")

</div>

Do you mean your result is something like

```auto
msg.payload
   array[]:
     0: "I was going to the store."
     1: "I fell and needed to take some medicine."
     2: "After I took the aspirin I got a rash."
     3: "Thanks,"
     4: "Joe Pierce"

```

?????

Have you thought about Splitting that array up, and then throwing it through a Switch node with some regex to find your keyword in the sentence/payload?
