<?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 foreach at the beginning of the query fetching less records than expected in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/using-foreach-at-the-beginning-of-the-query-fetching-less/m-p/365942#M107930</link>
    <description>&lt;P&gt;Change line 6 in your first example to &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search LoS != 1 OR isnull(LoS)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and see if they reappear.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Apr 2018 03:09:35 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2018-04-27T03:09:35Z</dc:date>
    <item>
      <title>using foreach at the beginning of the query fetching less records than expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-foreach-at-the-beginning-of-the-query-fetching-less/m-p/365940#M107928</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index="index1" tdr=tdr1 OR tdr=tdr2
transaction id
| foreach * [ rex field=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; mode=sed "s/{|}//g"]
| eval _time=strptime(Qtime,"%Y-%m-%d %H:%M:%S.%3N") 
| eval LoS=if(tdr=1,Cos,null)
| search LoS != 1 Los !=3 Los!=H LoS!=C
....
....
| table .....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above code returning 140 records. But the actual records are 200.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="index1" tdr=tdr1 OR tdr=tdr2
transaction id    
| eval _time=strptime(Qtime,"{%Y-%m-%d %H:%M:%S.%3N}") 
| eval LoS=if(tdr=1,Cos,null)
| search LoS != {1} Los !={3} Los!={H} LoS!={C}
....
....
| table .....
| foreach * [ rex field=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; mode=sed "s/{|}//g"]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above code is returning 200 records. &lt;/P&gt;

&lt;P&gt;Why foreach behaves differently in these two cases? &lt;BR /&gt;
Please help me to understand the issue.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 01:27:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-foreach-at-the-beginning-of-the-query-fetching-less/m-p/365940#M107928</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-04-27T01:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: using foreach at the beginning of the query fetching less records than expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-foreach-at-the-beginning-of-the-query-fetching-less/m-p/365941#M107929</link>
      <description>&lt;P&gt;I don't have an answer, but I wonder if it would help you (and us) track down the issue if you look at the events that are not returned, perhaps with a search like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="index1" tdr=tdr1 OR tdr=tdr2
 transaction id
 | foreach * [ rex field=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; mode=sed "s/{|}//g"]
 | eval _time=strptime(Qtime,"%Y-%m-%d %H:%M:%S.%3N") 
 | eval LoS=....
 | search LoS = 1
 | table .....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It's worth pointing out that since we can't see your &lt;CODE&gt;eval&lt;/CODE&gt; expression for LoS, it's tough to see the full picture of why searching for &lt;CODE&gt;!=1&lt;/CODE&gt; and &lt;CODE&gt;!={1}&lt;/CODE&gt; may return different sets of results.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 01:53:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-foreach-at-the-beginning-of-the-query-fetching-less/m-p/365941#M107929</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-04-27T01:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: using foreach at the beginning of the query fetching less records than expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-foreach-at-the-beginning-of-the-query-fetching-less/m-p/365942#M107930</link>
      <description>&lt;P&gt;Change line 6 in your first example to &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search LoS != 1 OR isnull(LoS)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and see if they reappear.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 03:09:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-foreach-at-the-beginning-of-the-query-fetching-less/m-p/365942#M107930</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-04-27T03:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: using foreach at the beginning of the query fetching less records than expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-foreach-at-the-beginning-of-the-query-fetching-less/m-p/365943#M107931</link>
      <description>&lt;P&gt;Updated my queries. Please have a look.&lt;BR /&gt;
tdrs always have the values with {} eg: {H} or {1}&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 16:41:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-foreach-at-the-beginning-of-the-query-fetching-less/m-p/365943#M107931</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-04-27T16:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: using foreach at the beginning of the query fetching less records than expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-foreach-at-the-beginning-of-the-query-fetching-less/m-p/365944#M107932</link>
      <description>&lt;P&gt;Its not working. It always has value with {1}&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 17:19:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-foreach-at-the-beginning-of-the-query-fetching-less/m-p/365944#M107932</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-04-27T17:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: using foreach at the beginning of the query fetching less records than expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-foreach-at-the-beginning-of-the-query-fetching-less/m-p/365945#M107933</link>
      <description>&lt;P&gt;In Example 1, Los always has a value = 1, since we strip off {} using foreach at the top before applying the condition check.&lt;/P&gt;</description>
      <pubDate>Tue, 01 May 2018 16:29:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-foreach-at-the-beginning-of-the-query-fetching-less/m-p/365945#M107933</guid>
      <dc:creator>rmuraly</dc:creator>
      <dc:date>2018-05-01T16:29:55Z</dc:date>
    </item>
  </channel>
</rss>

