<?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: Iterative subsearch (iterative OR search, at any rate) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Iterative-subsearch-iterative-OR-search-at-any-rate/m-p/85975#M21948</link>
    <description>&lt;P&gt;Based on the above discussion, I think that regarding carasso's answer, the &lt;CODE&gt;return&lt;/CODE&gt; command should be &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | return -1 $item ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;rather than&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | return -1 item ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which does what renaming the &lt;CODE&gt;item&lt;/CODE&gt; field to &lt;CODE&gt;search&lt;/CODE&gt; does.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Oct 2012 03:47:26 GMT</pubDate>
    <dc:creator>gkanapathy</dc:creator>
    <dc:date>2012-10-19T03:47:26Z</dc:date>
    <item>
      <title>Iterative subsearch (iterative OR search, at any rate)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Iterative-subsearch-iterative-OR-search-at-any-rate/m-p/85971#M21944</link>
      <description>&lt;P&gt;Looking for a sanity check here.  I want to search my Splunk for a long list of field values (essentially, an OR for each value) and the best way to get that list of values is by searching for them.&lt;/P&gt;

&lt;P&gt;So a subsearch seemed like the right path to travel, but yields no hits, so I'm unsure if that's my search or my data.&lt;/P&gt;

&lt;P&gt;I've tried:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;&lt;PRE&gt;
index=main [ search index=pp "item purchased" 
| rex field=_raw "obtained (?&lt;ITEM&gt;\w+)" 
| fields item ]
&lt;/ITEM&gt;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;With and without a | format at the end (based on searching here for others tryign to do what I am trying to do), or changing my wildcard * search for item="*" and so on.&lt;/P&gt;

&lt;P&gt;Basically, I want to find every occurrence in my Splunk for each item purchased.  I'm sure this is easy to do, I'm just missing something obvious.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2011 03:56:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Iterative-subsearch-iterative-OR-search-at-any-rate/m-p/85971#M21944</guid>
      <dc:creator>howyagoin</dc:creator>
      <dc:date>2011-04-21T03:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative subsearch (iterative OR search, at any rate)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Iterative-subsearch-iterative-OR-search-at-any-rate/m-p/85972#M21945</link>
      <description>&lt;P&gt;Say there are three results in the subsearch, it will come out into the main search clause looking like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main ( item=A OR item=B OR item=C )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I suspect that you dont want to search for a field called 'item', but you instead want to just search for  &lt;CODE&gt;(A OR B OR C)&lt;/CODE&gt;.   This is a little clunky but how you do that in a Splunk subsearch is you rename the field to either 'search' or 'query'. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main [ search index=pp "item purchased" 
| rex field=_raw "obtained (?&amp;lt;item&amp;gt;\w+)" 
| fields item | rename item as search]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Apr 2011 05:14:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Iterative-subsearch-iterative-OR-search-at-any-rate/m-p/85972#M21945</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-04-21T05:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative subsearch (iterative OR search, at any rate)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Iterative-subsearch-iterative-OR-search-at-any-rate/m-p/85973#M21946</link>
      <description>&lt;P&gt;Great, Nick, thanks.  By changing this to "as query" rather than "as search" the magic happened.  From 0 hits to 81,000, just like that.   Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2011 05:37:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Iterative-subsearch-iterative-OR-search-at-any-rate/m-p/85973#M21946</guid>
      <dc:creator>howyagoin</dc:creator>
      <dc:date>2011-04-21T05:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative subsearch (iterative OR search, at any rate)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Iterative-subsearch-iterative-OR-search-at-any-rate/m-p/85974#M21947</link>
      <description>&lt;P&gt;simpler.  replace the 'fields' and 'rename' with 'return', which also removes duplicates:&lt;/P&gt;

&lt;P&gt;index=main [ search index=pp "item purchased" &lt;BR /&gt;
     | rex field=_raw "obtained (?&lt;ITEM&gt;\w+)" &lt;BR /&gt;
     | return -1 item]&lt;/ITEM&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2012 03:18:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Iterative-subsearch-iterative-OR-search-at-any-rate/m-p/85974#M21947</guid>
      <dc:creator>carasso</dc:creator>
      <dc:date>2012-10-19T03:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative subsearch (iterative OR search, at any rate)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Iterative-subsearch-iterative-OR-search-at-any-rate/m-p/85975#M21948</link>
      <description>&lt;P&gt;Based on the above discussion, I think that regarding carasso's answer, the &lt;CODE&gt;return&lt;/CODE&gt; command should be &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | return -1 $item ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;rather than&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | return -1 item ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which does what renaming the &lt;CODE&gt;item&lt;/CODE&gt; field to &lt;CODE&gt;search&lt;/CODE&gt; does.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2012 03:47:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Iterative-subsearch-iterative-OR-search-at-any-rate/m-p/85975#M21948</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-10-19T03:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative subsearch (iterative OR search, at any rate)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Iterative-subsearch-iterative-OR-search-at-any-rate/m-p/85976#M21949</link>
      <description>&lt;P&gt;Yes, my bad.  "| return -1 $item" will return "val1 OR val2 OR val3", while "| return -1 item" will return "item=val1 OR item=val2 OR item=val3"&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2012 04:07:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Iterative-subsearch-iterative-OR-search-at-any-rate/m-p/85976#M21949</guid>
      <dc:creator>carasso</dc:creator>
      <dc:date>2012-10-19T04:07:53Z</dc:date>
    </item>
  </channel>
</rss>

