<?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 using NOT in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120154#M32265</link>
    <description>&lt;P&gt;There are two possibilities that could be throwing off your numbers 1) Not all &lt;CODE&gt;ThreadId&lt;/CODE&gt; in &lt;CODE&gt;datasummary2&lt;/CODE&gt; appears in &lt;CODE&gt;datasummary1&lt;/CODE&gt;, and 2) there could be duplication in your data (this is @richgalloway 's solution).&lt;/P&gt;

&lt;P&gt;Now to find the number of ThreadIds unique to each index, and the number of ThreadIds common to both you could use this query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=datasummary1 OR index=datasummary2 | stats values(index) as index by ThreadId | eval index=if(mvcount(index)==2,"both",index) | stats count by index
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alternatively if you want which ThreadIds are in each: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=datasummary1 OR index=datasummary2 | stats values(index) as index by ThreadId | eval index=if(mvcount(index)==2,"both",index) | stats values(ThreadId) as ThreadId by index
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or a slightly alternate solution for your problem: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=datasummary1 OR index=datasummary2 | stats values(index) as index by ThreadId | eval index=if(mvcount(index)==2,"both",index) | where index="datasummary1"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 22 May 2015 02:41:08 GMT</pubDate>
    <dc:creator>acharlieh</dc:creator>
    <dc:date>2015-05-22T02:41:08Z</dc:date>
    <item>
      <title>Search using NOT</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120151#M32262</link>
      <description>&lt;P&gt;I have a query like this to llist thread from datasummary1 which does'nt exist in datasummary2. (something like this below). I am not getting accurate results. Any ideas where the issue is ? &lt;/P&gt;

&lt;P&gt;if i run individual queries&lt;BR /&gt;
datasummary1 ==&amp;gt; 220000&lt;BR /&gt;
datasummary2 ==&amp;gt; 40000&lt;/P&gt;

&lt;P&gt;the below query give me somewhere around 210000, where i am expecting 180000. &lt;BR /&gt;
index=datasummary1 NOT [search index=datasummary2 | dedup  ThreadId | fields ThreadId] | table ThreadId&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2015 16:07:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120151#M32262</guid>
      <dc:creator>Sriram</dc:creator>
      <dc:date>2015-05-21T16:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: Search using NOT</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120152#M32263</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=datasummary1 NOT [search index=datasummary2] | dedup ThreadId | table ThreadId
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 May 2015 16:25:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120152#M32263</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-05-21T16:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: Search using NOT</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120153#M32264</link>
      <description>&lt;P&gt;Outer Join:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=datasummary1 OR index=datasummary2 | stats dc(index) AS indices BY ThreadId | where indices==1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 May 2015 01:49:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120153#M32264</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-05-22T01:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Search using NOT</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120154#M32265</link>
      <description>&lt;P&gt;There are two possibilities that could be throwing off your numbers 1) Not all &lt;CODE&gt;ThreadId&lt;/CODE&gt; in &lt;CODE&gt;datasummary2&lt;/CODE&gt; appears in &lt;CODE&gt;datasummary1&lt;/CODE&gt;, and 2) there could be duplication in your data (this is @richgalloway 's solution).&lt;/P&gt;

&lt;P&gt;Now to find the number of ThreadIds unique to each index, and the number of ThreadIds common to both you could use this query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=datasummary1 OR index=datasummary2 | stats values(index) as index by ThreadId | eval index=if(mvcount(index)==2,"both",index) | stats count by index
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alternatively if you want which ThreadIds are in each: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=datasummary1 OR index=datasummary2 | stats values(index) as index by ThreadId | eval index=if(mvcount(index)==2,"both",index) | stats values(ThreadId) as ThreadId by index
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or a slightly alternate solution for your problem: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=datasummary1 OR index=datasummary2 | stats values(index) as index by ThreadId | eval index=if(mvcount(index)==2,"both",index) | where index="datasummary1"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 May 2015 02:41:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120154#M32265</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2015-05-22T02:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: Search using NOT</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120155#M32266</link>
      <description>&lt;P&gt;This will also include &lt;CODE&gt;ThreadId&lt;/CODE&gt; values in &lt;CODE&gt;index=datasummary2&lt;/CODE&gt; that are not present in &lt;CODE&gt;index=datasummary1&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2015 02:43:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120155#M32266</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2015-05-22T02:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: Search using NOT</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120156#M32267</link>
      <description>&lt;P&gt;You'll want to keep the dedup within the subsearch so we're less likely to hit the subsearch limit. (in addition to the dedup outside that you've added)&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2015 02:45:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120156#M32267</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2015-05-22T02:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Search using NOT</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120157#M32268</link>
      <description>&lt;P&gt;It would be better you use &lt;STRONG&gt;eventstats&lt;/STRONG&gt; instead of &lt;STRONG&gt;stats&lt;/STRONG&gt; because it will retain the other fields.&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2015 04:06:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120157#M32268</guid>
      <dc:creator>Arun_N_007</dc:creator>
      <dc:date>2015-05-22T04:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Search using NOT</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120158#M32269</link>
      <description>&lt;P&gt;Depending on if I wanted other fields yes, but the way the question is worded leads me to believe that the goal is solely ThreadId by index in which case no need to keep around the bulk of additional fields. The original search ended with a table ThreadId which is more evidence to this assumption&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2015 04:11:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120158#M32269</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2015-05-22T04:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: Search using NOT</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120159#M32270</link>
      <description>&lt;P&gt;Oh my bad &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2015 04:15:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120159#M32270</guid>
      <dc:creator>Arun_N_007</dc:creator>
      <dc:date>2015-05-22T04:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: Search using NOT</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120160#M32271</link>
      <description>&lt;P&gt;Thank you all for quick response. As acharlieh correctly pointed out that The issue appears to be subsearch result limit causing the numbers to go awry. I set a limit of 60000 (it is still ugly, but it seems to be working) and also changed the 'fields ThreadId' to 'table ThreadId' as per richgalloway suggestion. &lt;/P&gt;

&lt;P&gt;index=datasummary1 ThreadId = "*" NOT [search index=datasummary2 | dedup ThreadId | table ThreadId | format maxresults=60000] | table ThreadId,EventDate,EventTime,status&lt;/P&gt;

&lt;P&gt;i will explore the other suggestions mentioned in the post as my subsearch limit will definitely be more 60000 at some point.  &lt;/P&gt;

&lt;P&gt;Thanks again. You guys are awesome !&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2015 15:09:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-using-NOT/m-p/120160#M32271</guid>
      <dc:creator>Sriram</dc:creator>
      <dc:date>2015-05-22T15:09:04Z</dc:date>
    </item>
  </channel>
</rss>

