<?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: Subsearch NOT in in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-NOT-in/m-p/21914#M3660</link>
    <description>&lt;P&gt;Yea the events dont appear in B. &lt;/P&gt;

&lt;P&gt;Although, as is described in the problem statement - there are tens of thousands of SERIAL_NUMBER that are present in sourectype A - that are also present in index B and the goal is to filter out ALL THESE SERIAL NUMBERS that appear in index B -  OUT OF A&lt;/P&gt;

&lt;P&gt;THe search described here does not work&lt;/P&gt;</description>
    <pubDate>Mon, 09 Apr 2012 21:30:25 GMT</pubDate>
    <dc:creator>asarolkar</dc:creator>
    <dc:date>2012-04-09T21:30:25Z</dc:date>
    <item>
      <title>Subsearch NOT in</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-NOT-in/m-p/21910#M3656</link>
      <description>&lt;P&gt;I have two sourcetypes A and B - each has a column SERIAL_NUMBER&lt;/P&gt;

&lt;P&gt;Sourcetype A has over 1000,000 records&lt;BR /&gt;
Sourcetype B has over 15,000 records&lt;/P&gt;

&lt;P&gt;I need every SERIAL_NUMBER in sourcetype A that is NOT present in sourcetype B - SO - I write a subsearch and insert a NOT in there  - like SO : &lt;/P&gt;

&lt;P&gt;sourcetype="A" SERIAL_NUMBER= * | search NOT [ search sourcetype="B" SERIAL_NUMBER= * | fields + SERIAL_NUMBER] | dedup SERIAL_NUMBER | table SERIAL_NUMBER&lt;/P&gt;

&lt;P&gt;Is there a better way to create this query ? &lt;/P&gt;

&lt;P&gt;I tried doing an outer join but that did not work out well&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:38:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-NOT-in/m-p/21910#M3656</guid>
      <dc:creator>asarolkar</dc:creator>
      <dc:date>2020-09-28T11:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch NOT in</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-NOT-in/m-p/21911#M3657</link>
      <description>&lt;P&gt;You don't need a subsearch.   Just use stats. &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype=A OR sourcetype=B | stats values(sourcetype) as sourcetypes by SERIAL_NUMBER | search sourcetypes!="B" | table SERIAL_NUMBER&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;It's very common for people to gravitate to complex joins and subsearches and overlook a simpler way to do the same thing with stats. &lt;/P&gt;

&lt;P&gt;In some cases subsearches offer the advantage of getting far fewer events off disk than a stats approach.  However in your case you need every one of these events off disk anyway so you can perform the comparison.  Thus the stats search is not only simpler but also a little faster because it can do all the work in a single search pipeline.   &lt;/P&gt;

&lt;P&gt;Furthermore you wont smack into the limits that subsearches have.  Despite looking like such an attractive general tool to new Splunk users, subsearches are designed to be used only when the searches are relatively fast, and the results returned are numbered in dozens or hundreds...    -- &lt;/P&gt;

&lt;P&gt;long-running subsearches will get finalized at the 60 second mark, and subsearches that generate more than 10,500 rows will get truncated there.  Both limits can obviously result in the final results being off. &lt;/P&gt;

&lt;P&gt;some links: &lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonStatsFunctions"&gt;Functions for stats, chart and timechart&lt;/A&gt; (if you're going to memorize just one page in the Splunk documentation, make it this one)&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/4.2.3/User/HowSubsearchesWork"&gt;Subsearches, when to use them, when not&lt;/A&gt;.     pay careful attention to 'maxout' and 'maxtime'.   Other limits on subsearches show up in append/join,  such that in several cases there can be more than one limit applying.  Again, subsearches are for cases where searches are fast and when they return only dozens or hundreds of results..&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Sun, 08 Apr 2012 19:03:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-NOT-in/m-p/21911#M3657</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2012-04-08T19:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch NOT in</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-NOT-in/m-p/21912#M3658</link>
      <description>&lt;P&gt;Hi nick !&lt;/P&gt;

&lt;P&gt;Thanks for your response&lt;/P&gt;

&lt;P&gt;Would the search be the same if the other was being written to just an index&lt;/P&gt;

&lt;P&gt;Meaning can I do &amp;gt;&amp;gt; sourcetype="A" OR index="B" and have the same desired outcome ? &lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 09 Apr 2012 00:41:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-NOT-in/m-p/21912#M3658</guid>
      <dc:creator>asarolkar</dc:creator>
      <dc:date>2012-04-09T00:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch NOT in</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-NOT-in/m-p/21913#M3659</link>
      <description>&lt;P&gt;assuming that sourcetype="A" events never appear in index="B", then yes it's about the same.  Although note there's an extra values clause: &lt;/P&gt;

&lt;P&gt;sourcetype="A" OR index="B" | stats values(sourcetype) as sourcetype values(index) as index by SERIAL_NUMBER | search index!="B" | table SERIAL_NUMBER&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:39:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-NOT-in/m-p/21913#M3659</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2020-09-28T11:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch NOT in</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-NOT-in/m-p/21914#M3660</link>
      <description>&lt;P&gt;Yea the events dont appear in B. &lt;/P&gt;

&lt;P&gt;Although, as is described in the problem statement - there are tens of thousands of SERIAL_NUMBER that are present in sourectype A - that are also present in index B and the goal is to filter out ALL THESE SERIAL NUMBERS that appear in index B -  OUT OF A&lt;/P&gt;

&lt;P&gt;THe search described here does not work&lt;/P&gt;</description>
      <pubDate>Mon, 09 Apr 2012 21:30:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-NOT-in/m-p/21914#M3660</guid>
      <dc:creator>asarolkar</dc:creator>
      <dc:date>2012-04-09T21:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch NOT in</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-NOT-in/m-p/21915#M3661</link>
      <description>&lt;P&gt;Sorry I had a typo in there.   The field I was creating was called 'indexes', and then I was searching using 'index!="B"'.  (Note indexes!=index).  I have corrected the search in the comment.  the correct search is &lt;BR /&gt;
sourcetype="A" OR index="B" | stats values(sourcetype) as sourcetype values(index) as index by SERIAL_NUMBER | search index!="B" | table SERIAL_NUMBER&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:39:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-NOT-in/m-p/21915#M3661</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2020-09-28T11:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch NOT in</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-NOT-in/m-p/21916#M3662</link>
      <description>&lt;P&gt;You should try &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;| set diff&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;to return results that are not common to both.&lt;BR /&gt;
Maybe you also need use&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;| set union&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;to get results in sourcetypes A. &lt;/P&gt;</description>
      <pubDate>Sun, 14 Apr 2013 23:40:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-NOT-in/m-p/21916#M3662</guid>
      <dc:creator>lzhang_soliton</dc:creator>
      <dc:date>2013-04-14T23:40:38Z</dc:date>
    </item>
  </channel>
</rss>

