<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using wildcard in mvfind in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-wildcard-in-mvfind/m-p/671834#M230196</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;- mvmap so it iterates like a for loop and checks. What if I want to do multiple checks.&lt;BR /&gt;Example, I want to check for different regions.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;mvcount(Region)&amp;gt;1, mvmap(Region, if(match(Region, "(?i)bangalore"), "Bangalore", null())&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Here it iterates and checks for banglore. What if I want to check for Singapore , USA , China and so on. ? Its becoming quite challenging, please help me&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Example :&amp;nbsp;&amp;nbsp;Test_loc_method2 is the output I want from Region&amp;nbsp; (mv field)&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;Region&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;Test_loc_method2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;sh Bangalore Test&lt;BR /&gt;Chennai&lt;BR /&gt;Hyderbad&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;Bangalore&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;test China 1&lt;BR /&gt;India&lt;BR /&gt;&lt;BR /&gt;&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;China&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;&lt;BR /&gt;Loc USA 2&lt;BR /&gt;London&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;USA&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
    <pubDate>Thu, 14 Dec 2023 05:32:10 GMT</pubDate>
    <dc:creator>Poojitha</dc:creator>
    <dc:date>2023-12-14T05:32:10Z</dc:date>
    <item>
      <title>Using wildcard in mvfind</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-wildcard-in-mvfind/m-p/671827#M230192</link>
      <description>&lt;P&gt;Hi All,&lt;BR /&gt;&lt;BR /&gt;I am facing error using wildcard in multivalue field. I am using mvfind to find a string.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;eval test_loc=case(isnotnull(Region,%bangalore%), Bangalore)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am just giving part of eval statement here&lt;BR /&gt;&lt;BR /&gt;Example&amp;nbsp; : Region =&amp;nbsp; "sh bangalore Test"&lt;BR /&gt;&lt;BR /&gt;The above eval statement should work on this Region and &lt;STRONG&gt;set test_loc = Bangalore.&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;I tried passing * and % (*bangalore*, %bangalore%) , but am getting error.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Please help me.&lt;BR /&gt;&lt;BR /&gt;Thanks ,&lt;BR /&gt;poojitha NV&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 04:03:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-wildcard-in-mvfind/m-p/671827#M230192</guid>
      <dc:creator>Poojitha</dc:creator>
      <dc:date>2023-12-14T04:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Using wildcard in mvfind</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-wildcard-in-mvfind/m-p/671828#M230193</link>
      <description>&lt;P&gt;It requires regex, so you can't use SQL style % nor simple wildcard, use &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;.*&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 04:10:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-wildcard-in-mvfind/m-p/671828#M230193</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-12-14T04:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using wildcard in mvfind</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-wildcard-in-mvfind/m-p/671829#M230194</link>
      <description>&lt;P&gt;and actually you probably mean&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;eval test_loc=case(isnotnull(mvfind(Region,".*bangalore.*")), Bangalore)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 14 Dec 2023 04:11:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-wildcard-in-mvfind/m-p/671829#M230194</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-12-14T04:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using wildcard in mvfind</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-wildcard-in-mvfind/m-p/671831#M230195</link>
      <description>&lt;P&gt;Few different ways to approach this if I understand you problem correctly&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
    | fields - _time
    | eval
        Region=split("Bangalore|seattle|bangalore|Galveston|sh bangalore Test", "|")
    ``` Different Eval Methods ```
    | eval
        test_loc_method1=mvfilter(match(Region, "(?i)bangalore")),
        test_loc_method2=mvdedup(
            case(
                isnull(Region), null(),
                mvcount(Region)==1, if(match(Region, "(?i)bangalore"), "Bangalore", null()),
                mvcount(Region)&amp;gt;1, mvmap(Region, if(match(Region, "(?i)bangalore"), "Bangalore", null()))
                )
            )
    
    ``` Rex Method ```
    | rex field=Region "(?&amp;lt;rec_loc&amp;gt;(?i)bangalore)"&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;Mostly just depends on how you want the outputted eval field to look.&lt;BR /&gt;&lt;BR /&gt;test_loc_method2 gives a clean single value result with a hardcoded result given that the regex pattern is found somewhere in the multivalue field.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1702528191322.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28512iFFE28FD22FCA8B09/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1702528191322.png" alt="dtburrows3_0-1702528191322.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 04:30:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-wildcard-in-mvfind/m-p/671831#M230195</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2023-12-14T04:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using wildcard in mvfind</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-wildcard-in-mvfind/m-p/671834#M230196</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;- mvmap so it iterates like a for loop and checks. What if I want to do multiple checks.&lt;BR /&gt;Example, I want to check for different regions.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;mvcount(Region)&amp;gt;1, mvmap(Region, if(match(Region, "(?i)bangalore"), "Bangalore", null())&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Here it iterates and checks for banglore. What if I want to check for Singapore , USA , China and so on. ? Its becoming quite challenging, please help me&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Example :&amp;nbsp;&amp;nbsp;Test_loc_method2 is the output I want from Region&amp;nbsp; (mv field)&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;Region&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;Test_loc_method2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;sh Bangalore Test&lt;BR /&gt;Chennai&lt;BR /&gt;Hyderbad&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;Bangalore&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;test China 1&lt;BR /&gt;India&lt;BR /&gt;&lt;BR /&gt;&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;China&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;&lt;BR /&gt;Loc USA 2&lt;BR /&gt;London&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;USA&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 14 Dec 2023 05:32:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-wildcard-in-mvfind/m-p/671834#M230196</guid>
      <dc:creator>Poojitha</dc:creator>
      <dc:date>2023-12-14T05:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using wildcard in mvfind</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-wildcard-in-mvfind/m-p/671838#M230199</link>
      <description>&lt;P&gt;I think you can match() on an MV field directly, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval test=if(match(city, "(?i)bangalore|hyderbad|chennai"), 1, 0)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 14 Dec 2023 06:23:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-wildcard-in-mvfind/m-p/671838#M230199</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-12-14T06:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Using wildcard in mvfind</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-wildcard-in-mvfind/m-p/671935#M230228</link>
      <description>&lt;P&gt;So using this method below I believe will do it.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;``` This join is to pull in an array of all Regions you want to search for in the 'Region' multivalue field ```
    ``` There are other way to make the list (hardcoded, macros, lookups) I'm just using a lookup as a POC for if the list is large and is easy to maintain ```
    | join type=left [ | inputlookup list_of_regions | stats values(list_of_regions) as list_of_regions | eval list_of_regions_array=mv_to_json_array(list_of_regions) | fields - list_of_regions  ]
    ``` Convert array to multivalue field of all regions to search for ```
    | eval
        list_of_regions=json_array_to_mv(list_of_regions_array)
    | fields - list_of_regions_array
    ``` Use the regions multivalue field to build a regex ```
    | eval
        list_of_regions_regex="(?i)(".mvjoin(list_of_regions, "|").")"
    ``` pipe in the regex build from regions into this eval to loop through multivalue fields ```
    | eval
        Test_loc_method2=case(
            isnull(Region), null(),
            mvcount(Region)==1, if(match(Region, $list_of_regions_regex$), replace(Region, ".*".$list_of_regions_regex$.".*", "\1"), null()),
            mvcount(Region)&amp;gt;1, mvmap(Region, if(match(Region, ".*".$list_of_regions_regex$.".*"), replace(Region, ".*".$list_of_regions_regex$.".*", "\1"), null()))
            )
    | fields - list_of_regions, list_of_regions_regex
    ``` Pipe in matches that returned into the 'list_of_regions' lookup to pull back a formatted version of the match. Note: This lookup definition must have case sensitivity turned off for this part to work as intended. ```
    | lookup list_of_regions list_of_regions as Test_loc_method2 OUTPUT list_of_regions as formatted_matched_region&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1702571641341.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28523i2A39CE242F520E10/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1702571641341.png" alt="dtburrows3_0-1702571641341.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Full SPL I used to generate this output&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
    | fields - _time
    | eval
        Region=split("sh Bangalore Test|Chennai|Hyderbad", "|")
    | append
        [
            | makeresults
                | fields - _time
                | eval
                    Region=split("test China 1|India| ", "|")
            ]
    | append
        [
            | makeresults
                | fields - _time
                | eval
                    Region=split(" |Loc USA 2|London", "|")
            ]
    | append
        [
            | makeresults
                | fields - _time
                | eval
                    Region=split("lowercased china to test|New York|usa (America)", "|")
            ]
    ``` This join is to pull in an array of all Regions you want to search for in the 'Region' multivalue field ```
    ``` There are other way to make the list (hardcoded, macros, lookups) I'm just using a lookup as a POC for if the list is large and is easy to maintain ```
    | join type=left [ | inputlookup list_of_regions | stats values(list_of_regions) as list_of_regions | eval list_of_regions_array=mv_to_json_array(list_of_regions) | fields - list_of_regions  ]
    ``` Convert array to multivalue field of all regions to search for ```
    | eval
        list_of_regions=json_array_to_mv(list_of_regions_array)
    | fields - list_of_regions_array
    ``` Use the regions multivalue field to build a regex ```
    | eval
        list_of_regions_regex="(?i)(".mvjoin(list_of_regions, "|").")"
    ``` pipe in the regex build from regions into this eval to loop through multivalue fields ```
    | eval
        Test_loc_method2=case(
            isnull(Region), null(),
            mvcount(Region)==1, if(match(Region, $list_of_regions_regex$), replace(Region, ".*".$list_of_regions_regex$.".*", "\1"), null()),
            mvcount(Region)&amp;gt;1, mvmap(Region, if(match(Region, ".*".$list_of_regions_regex$.".*"), replace(Region, ".*".$list_of_regions_regex$.".*", "\1"), null()))
            )
    | fields - list_of_regions, list_of_regions_regex
    ``` Pipe in matches that returned into the 'list_of_regions' lookup to pull back a formatted version of the match. Note: This lookup definition must have case sensitivity turned off for this part to work as intended. ```
    | lookup list_of_regions list_of_regions as Test_loc_method2 OUTPUT list_of_regions as formatted_matched_region&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Note: I created a lookup for this example with CSV named "list_of_regions.csv" and with lookup definition named "list_of_regions". On the definition I turned off the case-sensitivity to allow for a formatted region to be returned on the last step if desired.&lt;BR /&gt;&lt;BR /&gt;You don't necessarily have to use a lookup for this method to work, I just found that if the list gets large that storing them in lookups sometimes makes things easier to maintain.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;If you only really need to use the list of regions for a single search you could probably just have them hardcoded into the search itself (Or just build the hardcoded regex based of your list)&lt;BR /&gt;&lt;BR /&gt;I just was sharing how you can sometimes pipe in $token$ into an eval function and it seemed to fit your use-case here.&lt;BR /&gt;&lt;BR /&gt;And for reference of what the lookup looks like here is a screenshot of what I used for this.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1702572041470.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28526i2721B284064D54A7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1702572041470.png" alt="dtburrows3_0-1702572041470.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 16:40:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-wildcard-in-mvfind/m-p/671935#M230228</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2023-12-14T16:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using wildcard in mvfind</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-wildcard-in-mvfind/m-p/672112#M230269</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;: I was able to achieve using case statement and the regex you gave. Thanks a lot &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Dec 2023 07:41:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-wildcard-in-mvfind/m-p/672112#M230269</guid>
      <dc:creator>Poojitha</dc:creator>
      <dc:date>2023-12-17T07:41:27Z</dc:date>
    </item>
  </channel>
</rss>

