<?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: eval searchmatch  with OR in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115172#M30464</link>
    <description>&lt;P&gt;This is the way you would use OR with rex.  If your strings are correct, then this should work with the exception of /Product/Product.*Overview/.  I left that out because from the looks of it you are specifying the overview/X strings that you want, and you said there are many that you don't want:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex field="cs_uri_stem" ".*(?&amp;lt;PRODUCT&amp;gt;/Product/Product.*Overview/Global.*|/Product/Product.*Overview/EMEA/.*|/Product/Product.*Overview/APAC/.*|/Product/Product.*Overview/Americas/.*)$" | eval Contact=if(match(cs_uri_stem,"/Contacts/ContactProfile/"),1,null()) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 25 Oct 2013 14:26:28 GMT</pubDate>
    <dc:creator>lukejadamec</dc:creator>
    <dc:date>2013-10-25T14:26:28Z</dc:date>
    <item>
      <title>eval searchmatch  with OR</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115167#M30459</link>
      <description>&lt;P&gt;I am trying to do a search match based on a number of different criteria.&lt;/P&gt;

&lt;P&gt;The below does not work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="iis-2" | extract auto=true | search cs_username | eval Product=if(searchmatch("cs_uri_stem=*/Product/Product*Overview/|*/Product/Product*Overview/Global*|*/Product/Product*Overview/EMEA/*|*/Product/Product*Overview/APAC/|*/Product/Product*Overview/Americas/"),1,null()) | stats count(Product) as Product by date_month
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The below does return results but I want to combine Product 1-5 into one column and add the results.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="iis-2" | extract auto=true | search cs_username |
eval Product1=if(searchmatch("cs_uri_stem=*/Product/Product*Overview/ |
eval Product2=if(searchmatch("cs_uri_stem=*/Product/Product*Overview/Global*"),1,null()) |
eval Product3=if(searchmatch("cs_uri_stem=*/Product/Product*Overview/EMEA/*"),1,null()) |
eval Product4=if(searchmatch("cs_uri_stem=*/Product/Product*Overview/APAC/*"),1,null()) |
eval Product5=if(searchmatch("cs_uri_stem=*/Product/Product*Overview/Americas/*"),1,null()) |
stats count(Product1) as Product1 count(Product2) as Product2 count(Product3) as Product3 count(Product4) as Product4 count(Product5) as Product5 by date_month
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I cant use &lt;CODE&gt;*/Product/Product*Overview/*&lt;/CODE&gt; as there are pages other than the ones above I do not want to include.&lt;/P&gt;

&lt;P&gt;I am stuck, hope you can help.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2013 11:09:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115167#M30459</guid>
      <dc:creator>DanielFordWA</dc:creator>
      <dc:date>2013-10-25T11:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: eval searchmatch  with OR</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115168#M30460</link>
      <description>&lt;P&gt;I've never been able to get regex or wildcards to work in an if statement.  You're best bet is probably creating a rex that will create a field for each.  Once you have them as fields, then you can do pretty much whatever you want.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2013 11:19:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115168#M30460</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2013-10-25T11:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: eval searchmatch  with OR</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115169#M30461</link>
      <description>&lt;P&gt;Thanks for the reply. I have not done this before, how would I go about doing this?&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2013 11:25:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115169#M30461</guid>
      <dc:creator>DanielFordWA</dc:creator>
      <dc:date>2013-10-25T11:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: eval searchmatch  with OR</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115170#M30462</link>
      <description>&lt;P&gt;Something like this:&lt;BR /&gt;
sourcetype="iis-2" | extract auto=true | search cs_username |rex field=cs_uri_stem ".*(?&lt;GLOBAL&gt;/Product/Product*Overview/Global)$"&lt;BR /&gt;
This probably won't work because I don't have the entire value string, but that is basically it to create a field called Global for that stem.&lt;BR /&gt;
Can you post the full cs_uri_stem values?&lt;/GLOBAL&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:04:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115170#M30462</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2020-09-28T15:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: eval searchmatch  with OR</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115171#M30463</link>
      <description>&lt;P&gt;The problem with searchmatch is that is not regex, so separating searches with "|" (or) will not work. You can do it this way:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype="iis-2" | extract auto=true | search cs_username | eval Product=if(match(cs_uri_stem,"*/Product/Product*Overview/"),1,if(match(cs_uri_stem,"*/Product/Product*Overview/Global*"),1,if(match(cs_uri_stem,"*/Product/Product*Overview/EMEA/*"),1,if(match(cs_uri_stem),"*/Product/Product*Overview/APAC/"),1,if(match(cs_uri_stem,"*/Product/Product*Overview/Americas/"),1,null())))) | stats count(Product) as Product by date_month&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Or A Non-nested version:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype="iis-2" | extract auto=true | search cs_username | eval Product=case(match(cs_uri_stem,"*/Product/Product*Overview/"),1,match(cs_uri_stem,"*/Product/Product*Overview/Global*"),1,match(cs_uri_stem,"*/Product/Product*Overview/EMEA/*"),1,match(cs_uri_stem,"*/Product/Product*Overview/APAC/"),1,match(cs_uri_stem,"*/Product/Product*Overview/Americas/"),1,1=1,null()) | stats count(Product) as Product by date_month&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;UPDATE&lt;/STRONG&gt;&lt;BR /&gt;
I fixed the syntax on the two searches. &lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2013 11:35:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115171#M30463</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2013-10-25T11:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: eval searchmatch  with OR</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115172#M30464</link>
      <description>&lt;P&gt;This is the way you would use OR with rex.  If your strings are correct, then this should work with the exception of /Product/Product.*Overview/.  I left that out because from the looks of it you are specifying the overview/X strings that you want, and you said there are many that you don't want:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex field="cs_uri_stem" ".*(?&amp;lt;PRODUCT&amp;gt;/Product/Product.*Overview/Global.*|/Product/Product.*Overview/EMEA/.*|/Product/Product.*Overview/APAC/.*|/Product/Product.*Overview/Americas/.*)$" | eval Contact=if(match(cs_uri_stem,"/Contacts/ContactProfile/"),1,null()) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Oct 2013 14:26:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115172#M30464</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2013-10-25T14:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: eval searchmatch  with OR</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115173#M30465</link>
      <description>&lt;P&gt;Did either of these work for you?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2013 19:26:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115173#M30465</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2013-10-29T19:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: eval searchmatch  with OR</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115174#M30466</link>
      <description>&lt;P&gt;Hi, Thanks for the response, I am just testing them now.&lt;/P&gt;

&lt;P&gt;The first query comes back with...&lt;/P&gt;

&lt;P&gt;Error in 'eval' command: The operator at ')' is invalid.&lt;/P&gt;

&lt;P&gt;The Non-nested version come back with... &lt;/P&gt;

&lt;P&gt;Error in 'eval' command: The operator at ',null())' is invalid.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2013 10:38:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115174#M30466</guid>
      <dc:creator>DanielFordWA</dc:creator>
      <dc:date>2013-10-30T10:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: eval searchmatch  with OR</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115175#M30467</link>
      <description>&lt;P&gt;This works great, however I do need the....&lt;/P&gt;

&lt;P&gt;/Product/Product.*Overview/ &lt;/P&gt;

&lt;P&gt;It used to be the case that this page was split by geo location and it is now not the case, so to do a query over the year I would need to include the below page but no pages underneath it.&lt;/P&gt;

&lt;P&gt;/Product/Product.*Overview/&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2013 10:44:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115175#M30467</guid>
      <dc:creator>DanielFordWA</dc:creator>
      <dc:date>2013-10-30T10:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: eval searchmatch  with OR</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115176#M30468</link>
      <description>&lt;P&gt;I just added /Product/Product.*Overview/. to the query and it works great.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2013 10:49:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115176#M30468</guid>
      <dc:creator>DanielFordWA</dc:creator>
      <dc:date>2013-10-30T10:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: eval searchmatch  with OR</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115177#M30469</link>
      <description>&lt;P&gt;Is it possible to combine this in a query where I am also using eval on the cs_uri_stem,&lt;BR /&gt;
eval Contact=if(match(cs_uri_stem,"&lt;EM&gt;/Contacts/*Contact*Profile/&lt;/EM&gt;"),1,null()) |&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:08:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115177#M30469</guid>
      <dc:creator>DanielFordWA</dc:creator>
      <dc:date>2020-09-28T15:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: eval searchmatch  with OR</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115178#M30470</link>
      <description>&lt;P&gt;Yes, if you also want to create the field Contact when the stem = that value only, then you would include that eval statement at the end.  I tested it with different stems and it worked.  I updated the query.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2013 13:27:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-searchmatch-with-OR/m-p/115178#M30470</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2013-10-30T13:27:36Z</dc:date>
    </item>
  </channel>
</rss>

