<?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: Searchmatch not returning expected result in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Searchmatch-not-returning-expected-result/m-p/53758#M179725</link>
    <description>&lt;P&gt;Converting to the regex method works great. Thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 05 Aug 2011 14:30:47 GMT</pubDate>
    <dc:creator>chca</dc:creator>
    <dc:date>2011-08-05T14:30:47Z</dc:date>
    <item>
      <title>Searchmatch not returning expected result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searchmatch-not-returning-expected-result/m-p/53756#M179723</link>
      <description>&lt;PRE&gt;
search * | eval userAgentType=if(searchmatch("cs_User_Agent_=*MSIE*"), "Internet Explorer", "Other") | search userAgentType="Other" cs_User_Agent_=*MSIE*
&lt;/PRE&gt;

&lt;P&gt;Based upon that search, there should be no results. The eval should assign all cs_User_Agent_ fields that do not contain "MSIE" to "Other", and then the following search should only display results that are of type "Other" and include "MSIE." However, that is not the case--several results display. Any idea why?&lt;/P&gt;

&lt;P&gt;Here's an example of the data:&lt;BR /&gt;
&lt;PRE&gt;&lt;BR /&gt;
Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+6.0;+WOW64;+GTB6.6;+SLCC1;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.04506;+Media+Center+PC+5.0)&lt;BR /&gt;
&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;UPDATE&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I've discovered that including the field in the searchmatch call is causing the false negatives. Can you not specify a field name as part of the searchmatch parameter?&lt;BR /&gt;
Works: &lt;/P&gt;

&lt;PRE&gt;
searchmatch("*MSIE*")
&lt;/PRE&gt;

&lt;P&gt;Doesn't work: &lt;BR /&gt;
&lt;PRE&gt;&lt;BR /&gt;
searchmatch("cs_User_Agent_=&lt;EM&gt;MSIE&lt;/EM&gt;")&lt;BR /&gt;
&lt;/PRE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:46:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searchmatch-not-returning-expected-result/m-p/53756#M179723</guid>
      <dc:creator>chca</dc:creator>
      <dc:date>2020-09-28T09:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: Searchmatch not returning expected result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searchmatch-not-returning-expected-result/m-p/53757#M179724</link>
      <description>&lt;P&gt;Try either &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;searchmatch("cs_User_Agent=\"*MSIE*\"")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if this is in the GUI, or whatever you need to do to include double-quotes in your search string if not in the GUI.&lt;/P&gt;

&lt;P&gt;Or, you can try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;match(cs_User_Agent,"MSIE")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which is probably more efficient anyway.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2011 03:58:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searchmatch-not-returning-expected-result/m-p/53757#M179724</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-08-05T03:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Searchmatch not returning expected result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searchmatch-not-returning-expected-result/m-p/53758#M179725</link>
      <description>&lt;P&gt;Converting to the regex method works great. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2011 14:30:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searchmatch-not-returning-expected-result/m-p/53758#M179725</guid>
      <dc:creator>chca</dc:creator>
      <dc:date>2011-08-05T14:30:47Z</dc:date>
    </item>
  </channel>
</rss>

