<?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: Search result evaluates to true when it is false in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-result-evaluates-to-true-when-it-is-false/m-p/710017#M239924</link>
    <description>&lt;P&gt;Hi, use spath :&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.4.0/SearchReference/Spath" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.4.0/SearchReference/Spath&lt;/A&gt;&lt;/P&gt;&lt;P&gt;To see why it happens, add and eval with just&lt;STRONG&gt; | eval subject2=Item.Subject ... | table ..., subject2&amp;nbsp;&lt;BR /&gt;(subject2 be null)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I have a splunk index in JSON that has the key SRV and key CONTENT_LENGTH.&lt;BR /&gt;If i do&lt;/P&gt;&lt;PRE&gt;index=someindex &lt;BR /&gt;| eval CONTENT_TYPE=if(isnull(SRV.CONTENT_TYPE),"true","false") &lt;BR /&gt;| table SRV.CONTENT_TYPE, CONTENT_TYPE&lt;/PRE&gt;&lt;P&gt;I will get the same problem as you do.&lt;/P&gt;&lt;P&gt;But like below, i dont :&lt;/P&gt;&lt;PRE&gt;index=someindex &lt;BR /&gt;| spath output=qwe "SRV.CONTENT_TYPE" &lt;BR /&gt;| eval CONTENT_TYPE=if(isnull(qwe),"true","false") &lt;BR /&gt;| table SRV.CONTENT_TYPE, CONTENT_TYPE&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jan 2025 18:30:06 GMT</pubDate>
    <dc:creator>alex_tc80</dc:creator>
    <dc:date>2025-01-28T18:30:06Z</dc:date>
    <item>
      <title>Search result evaluates to true when it is false</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-result-evaluates-to-true-when-it-is-false/m-p/710001#M239922</link>
      <description>&lt;P&gt;Hello, trying to figure out why this eval statement testing for a null value always evaluates to "true", even when the field does contain data:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="shaunm001_1-1738084615547.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/34271i5ADA2C7FFBC6F1DA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="shaunm001_1-1738084615547.png" alt="shaunm001_1-1738084615547.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is what the data looks like in the results:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="shaunm001_2-1738084765526.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/34272iA2B32B3308EFFE35/image-size/medium?v=v2&amp;amp;px=400" role="button" title="shaunm001_2-1738084765526.png" alt="shaunm001_2-1738084765526.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 17:20:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-result-evaluates-to-true-when-it-is-false/m-p/710001#M239922</guid>
      <dc:creator>shaunm001</dc:creator>
      <dc:date>2025-01-28T17:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Search result evaluates to true when it is false</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-result-evaluates-to-true-when-it-is-false/m-p/710017#M239924</link>
      <description>&lt;P&gt;Hi, use spath :&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.4.0/SearchReference/Spath" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.4.0/SearchReference/Spath&lt;/A&gt;&lt;/P&gt;&lt;P&gt;To see why it happens, add and eval with just&lt;STRONG&gt; | eval subject2=Item.Subject ... | table ..., subject2&amp;nbsp;&lt;BR /&gt;(subject2 be null)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I have a splunk index in JSON that has the key SRV and key CONTENT_LENGTH.&lt;BR /&gt;If i do&lt;/P&gt;&lt;PRE&gt;index=someindex &lt;BR /&gt;| eval CONTENT_TYPE=if(isnull(SRV.CONTENT_TYPE),"true","false") &lt;BR /&gt;| table SRV.CONTENT_TYPE, CONTENT_TYPE&lt;/PRE&gt;&lt;P&gt;I will get the same problem as you do.&lt;/P&gt;&lt;P&gt;But like below, i dont :&lt;/P&gt;&lt;PRE&gt;index=someindex &lt;BR /&gt;| spath output=qwe "SRV.CONTENT_TYPE" &lt;BR /&gt;| eval CONTENT_TYPE=if(isnull(qwe),"true","false") &lt;BR /&gt;| table SRV.CONTENT_TYPE, CONTENT_TYPE&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 18:30:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-result-evaluates-to-true-when-it-is-false/m-p/710017#M239924</guid>
      <dc:creator>alex_tc80</dc:creator>
      <dc:date>2025-01-28T18:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: Search result evaluates to true when it is false</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-result-evaluates-to-true-when-it-is-false/m-p/710020#M239925</link>
      <description>&lt;P&gt;Ahh..thanks, this was killing me. I was also having trouble with the eval statement checking an array value (kept erroring out), but seems like spath was the key there as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This ended up working for me:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=someindex
| spath output=sentSubject "Item.Subject"
| spath output=receivedSubject "AffectedItems{}.Subject"
| eval subject = if(isnull(sentSubject),receivedSubject,sentSubject)
| table UserId,subject,Operation, _time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 18:45:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-result-evaluates-to-true-when-it-is-false/m-p/710020#M239925</guid>
      <dc:creator>shaunm001</dc:creator>
      <dc:date>2025-01-28T18:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Search result evaluates to true when it is false</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-result-evaluates-to-true-when-it-is-false/m-p/710114#M239938</link>
      <description>&lt;P&gt;You are doing&lt;/P&gt;&lt;PRE&gt;isnull(Item.Subject)&lt;/PRE&gt;&lt;P&gt;Since you are not enclosing the Item.Subject part in quotes (in this case - you should use single quotes) Splunk treats Item and Subject as separate field names and tries to concatenate (the dot operator) their values. Since you have no fields called neither Item nor Subject in your data, the result of joining two null values is of course null as well.&lt;/P&gt;&lt;P&gt;You should do&lt;/P&gt;&lt;PRE&gt;isnull('Item.Subject')&lt;/PRE&gt;&lt;P&gt;to get a correct result.&lt;/P&gt;&lt;P&gt;Spath is not needed and since Splunk has already done automatic json extraction, it's a needless performance hit.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 10:22:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-result-evaluates-to-true-when-it-is-false/m-p/710114#M239938</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-01-29T10:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: Search result evaluates to true when it is false</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-result-evaluates-to-true-when-it-is-false/m-p/710156#M239939</link>
      <description>&lt;P&gt;Great, this also works and is actually simpler than the spath solution, thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 16:11:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-result-evaluates-to-true-when-it-is-false/m-p/710156#M239939</guid>
      <dc:creator>shaunm001</dc:creator>
      <dc:date>2025-01-29T16:11:40Z</dc:date>
    </item>
  </channel>
</rss>

