<?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: NOT Subsearch in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/NOT-Subsearch/m-p/44678#M10540</link>
    <description>&lt;P&gt;You'll need to correlate the open and closed events somehow. You could do this with the transaction command, then return only events that aren't closed (that is, where the 'closed_txn' field the transaction command creates is equal to 0). You could also do a join, or selfjoin and then add " | where event!=closed " to your search.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jan 2012 21:02:24 GMT</pubDate>
    <dc:creator>rtadams89</dc:creator>
    <dc:date>2012-01-06T21:02:24Z</dc:date>
    <item>
      <title>NOT Subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/NOT-Subsearch/m-p/44675#M10537</link>
      <description>&lt;P&gt;Hi &lt;BR /&gt;
1) Index=test event=initiated | dedup ip-address | table ip-address    gives me the initiated transactions.&lt;BR /&gt;
2) Index=test event=closed | dedup ip-address | table ip-address    gives the closed transactions. &lt;/P&gt;

&lt;P&gt;I need to display active transactions. so i need to remove the ip-address's of sub search from main search. I tried NOT and it didnt work. also is there any limit for sub search. the above searches return millions of records. &lt;/P&gt;

&lt;P&gt;please let me know the better approach for it.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2012 00:09:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/NOT-Subsearch/m-p/44675#M10537</guid>
      <dc:creator>praveenvemuri</dc:creator>
      <dc:date>2012-01-05T00:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: NOT Subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/NOT-Subsearch/m-p/44676#M10538</link>
      <description>&lt;P&gt;This should be your search:&lt;/P&gt;

&lt;P&gt;Index=test event=initiated | dedup ip-address | table ip-address | search NOT [search Index=test event=closed | dedup ip-address | table ip-address]&lt;/P&gt;

&lt;P&gt;I don't think that a sub-search has more limitation rather than the main-search.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2012 15:03:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/NOT-Subsearch/m-p/44676#M10538</guid>
      <dc:creator>rschutt</dc:creator>
      <dc:date>2012-01-06T15:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: NOT Subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/NOT-Subsearch/m-p/44677#M10539</link>
      <description>&lt;P&gt;Hi rschutt, Thanks fro responding. for some reason it is not working. it is displaying all the values same as Index=test event=initiated | dedup ip-address | table ip-address.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2012 20:50:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/NOT-Subsearch/m-p/44677#M10539</guid>
      <dc:creator>praveenvemuri</dc:creator>
      <dc:date>2012-01-06T20:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: NOT Subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/NOT-Subsearch/m-p/44678#M10540</link>
      <description>&lt;P&gt;You'll need to correlate the open and closed events somehow. You could do this with the transaction command, then return only events that aren't closed (that is, where the 'closed_txn' field the transaction command creates is equal to 0). You could also do a join, or selfjoin and then add " | where event!=closed " to your search.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2012 21:02:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/NOT-Subsearch/m-p/44678#M10540</guid>
      <dc:creator>rtadams89</dc:creator>
      <dc:date>2012-01-06T21:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: NOT Subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/NOT-Subsearch/m-p/44679#M10541</link>
      <description>&lt;P&gt;Has anyone answered this question ?? Because I noticed that the NOT that precedes a subsearch only gets applied to the first result in the subsearch.. I think using rex mode sed could be a useful here&lt;/P&gt;</description>
      <pubDate>Mon, 16 Feb 2015 14:04:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/NOT-Subsearch/m-p/44679#M10541</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2015-02-16T14:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: NOT Subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/NOT-Subsearch/m-p/44680#M10542</link>
      <description>&lt;P&gt;Hello praveenvemuri,&lt;/P&gt;

&lt;P&gt;I had the same problem and I fixed it using return and rex mode=sed. &lt;/P&gt;

&lt;P&gt;To do so, in your subsearch first start by returning the ip-address. That will output the result as &lt;STRONG&gt;(ip-address=X.X.X.X.X) OR (ip-address=Y.Y.Y.Y).....&lt;/STRONG&gt;  Once you have that, add a regex to take off the OR and replace it with NOT :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex mode=sed field=search "s/OR/NOT/g"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That would leave you with a subsearch result that looks like this:&lt;BR /&gt;
 &lt;STRONG&gt;(ip-address=X.X.X.X.X) NOT (ip-address=Y.Y.Y.Y) NOT.....&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Then all you have to do is add that subsearch to your search and add a NOT in front of it because there is no NOT in front of the first ip-address in the generated list.&lt;/P&gt;

&lt;P&gt;Your final search should look like that:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Index=test event=initiated | dedup ip-address | table ip-address | search NOT [search Index=test event=closed | dedup ip-address  |return 100000 ip-address| rex mode=sed field=ip-address "s/OR/NOT/g"]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know how that work out for you even if its a 2 years later answer lol&lt;/P&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
David&lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2015 09:30:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/NOT-Subsearch/m-p/44680#M10542</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2015-02-17T09:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: NOT Subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/NOT-Subsearch/m-p/44681#M10543</link>
      <description>&lt;P&gt;There is a typo in the final search &lt;/P&gt;

&lt;P&gt;rex mode=sed field=&lt;STRONG&gt;search&lt;/STRONG&gt; ...&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2016 09:55:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/NOT-Subsearch/m-p/44681#M10543</guid>
      <dc:creator>MSimon</dc:creator>
      <dc:date>2016-12-01T09:55:17Z</dc:date>
    </item>
  </channel>
</rss>

