<?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: Why are fields returning true for both isNum() and isStr() ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-are-fields-returning-true-for-both-isNum-and-isStr/m-p/166016#M47247</link>
    <description>&lt;P&gt;Thank you for your reply, it makes perfect sense.&lt;/P&gt;</description>
    <pubDate>Mon, 20 Oct 2014 04:21:09 GMT</pubDate>
    <dc:creator>rolaso</dc:creator>
    <dc:date>2014-10-20T04:21:09Z</dc:date>
    <item>
      <title>Why are fields returning true for both isNum() and isStr() ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-are-fields-returning-true-for-both-isNum-and-isStr/m-p/166014#M47245</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I want to setup a search to alarm me if a field ever changes its nature. To play around, I chose the year field in one of our indexes. This field appears to be numeric.&lt;/P&gt;

&lt;P&gt;field k="date_year" c="20" nc="20" dc="1" exact="1" relevant="0"&lt;/P&gt;

&lt;P&gt;All 20 counts are numeric, hence it should be numeric.&lt;/P&gt;

&lt;P&gt;I would expect this simple search to have isNum=true and isStr=false for all fields:&lt;/P&gt;

&lt;P&gt;index=foo &lt;BR /&gt;
| eval isStr= if(isstr(date_year),"true","false")&lt;BR /&gt;
| eval isNum= if(isnum(date_year),"true","false")&lt;BR /&gt;
| table isNum,isStr, date_year&lt;/P&gt;

&lt;P&gt;But this is what I get:&lt;/P&gt;

&lt;P&gt;isNum   isStr   date_year&lt;BR /&gt;
true    true            2014&lt;BR /&gt;
true            true            2014&lt;BR /&gt;
true            true            2014&lt;/P&gt;

&lt;P&gt;I have done some research, and I can't find any posts about this behaviour. Can someone explain to me why this is happening?&lt;/P&gt;

&lt;P&gt;Many thanks!&lt;/P&gt;

&lt;P&gt;R&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:54:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-are-fields-returning-true-for-both-isNum-and-isStr/m-p/166014#M47245</guid>
      <dc:creator>rolaso</dc:creator>
      <dc:date>2020-09-28T17:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why are fields returning true for both isNum() and isStr() ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-are-fields-returning-true-for-both-isNum-and-isStr/m-p/166015#M47246</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/35743"&gt;@rolaso&lt;/a&gt;&lt;/P&gt;

&lt;P&gt;I think the reason isStr is returning "true" is because numeric values are also considered strings. I was just looking through Splunk &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1.4/Search/Aboutsearchlanguagesyntax#Fields" target="_blank"&gt;documentation&lt;/A&gt; and found this:&lt;/P&gt;

&lt;P&gt;"Numbers, for example, are strings that contain the number. For example, a field containing a value of the number 10 contains the characters 1 and 0: "10""&lt;/P&gt;

&lt;P&gt;The date_year field will always be a number, so 2014 could be seen as containing the characters 2, 0, 1, 4: "2014", so it makes sense that | eval isStr= if(isstr(date_year),"true","false") would return "true".&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:54:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-are-fields-returning-true-for-both-isNum-and-isStr/m-p/166015#M47246</guid>
      <dc:creator>ppablo</dc:creator>
      <dc:date>2020-09-28T17:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why are fields returning true for both isNum() and isStr() ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-are-fields-returning-true-for-both-isNum-and-isStr/m-p/166016#M47247</link>
      <description>&lt;P&gt;Thank you for your reply, it makes perfect sense.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Oct 2014 04:21:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-are-fields-returning-true-for-both-isNum-and-isStr/m-p/166016#M47247</guid>
      <dc:creator>rolaso</dc:creator>
      <dc:date>2014-10-20T04:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Why are fields returning true for both isNum() and isStr() ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-are-fields-returning-true-for-both-isNum-and-isStr/m-p/166017#M47248</link>
      <description>&lt;P&gt;No problem @rolaso glad I could clarify.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Oct 2014 04:27:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-are-fields-returning-true-for-both-isNum-and-isStr/m-p/166017#M47248</guid>
      <dc:creator>ppablo</dc:creator>
      <dc:date>2014-10-20T04:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Why are fields returning true for both isNum() and isStr() ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-are-fields-returning-true-for-both-isNum-and-isStr/m-p/166018#M47249</link>
      <description>&lt;P&gt;Under which scenarios does isstr return false then other than empty/null?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 10:57:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-are-fields-returning-true-for-both-isNum-and-isStr/m-p/166018#M47249</guid>
      <dc:creator>Nikobobinus</dc:creator>
      <dc:date>2018-12-03T10:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: Why are fields returning true for both isNum() and isStr() ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-are-fields-returning-true-for-both-isNum-and-isStr/m-p/511233#M143239</link>
      <description>&lt;P&gt;Is this a claim that isnum() and isstr() are deprecated?&amp;nbsp; This was working up until recently.&amp;nbsp; I've been scratching my head for hours trying to fix my dashboard.&lt;/P&gt;&lt;P&gt;If this is the case then there needs to be a way to find out if a string containing only numbers is indeed only numbers.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2020 21:36:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-are-fields-returning-true-for-both-isNum-and-isStr/m-p/511233#M143239</guid>
      <dc:creator>weidertc</dc:creator>
      <dc:date>2020-07-27T21:36:16Z</dc:date>
    </item>
  </channel>
</rss>

