<?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 in search command not returning results in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-in-search-command-not-returning-results/m-p/83553#M21284</link>
    <description>&lt;P&gt;This is exactly what I was looking for, thank you!&lt;/P&gt;</description>
    <pubDate>Wed, 03 Apr 2013 18:29:13 GMT</pubDate>
    <dc:creator>msarro</dc:creator>
    <dc:date>2013-04-03T18:29:13Z</dc:date>
    <item>
      <title>Subsearch in search command not returning results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-in-search-command-not-returning-results/m-p/83551#M21282</link>
      <description>&lt;P&gt;Hey everyone, I am pretty sure this is a simple question, but I'd appreciate a sanity check.&lt;/P&gt;

&lt;P&gt;When I run the following command I get a list of values (2910 results, suppose one value is the string "ReturnedValueX"):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mysearchindex host=myserver* My_Field="901089187"|table MY_OTHER_FIELD
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When i try to run it as a subsearch to another search command however, I get 0 results.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myothersearchindex host="myserver*" [search index=mysearchindex host=myserver* My_Field="901089187"|table MY_OTHER_FIELD]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;BUT, if I take one of the values from MY_OTHER_FIELD and use it as a string in the search command like this I get results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myothersearchindex host="myserver*" "ReturnedValueX"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The only possible issues I can think of are:&lt;BR /&gt;
1) The number of results from the subsearch is too high&lt;BR /&gt;
2) There are no defined fields in index=myothersearchindex, just raw log data. The goal is to take the list of string values from the subsearch and use it to limit the results of the outer search.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:39:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-in-search-command-not-returning-results/m-p/83551#M21282</guid>
      <dc:creator>msarro</dc:creator>
      <dc:date>2020-09-28T13:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch in search command not returning results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-in-search-command-not-returning-results/m-p/83552#M21283</link>
      <description>&lt;P&gt;Hello msarro,&lt;/P&gt;

&lt;P&gt;I think I see what you are trying to do which is to pass the values up from a subsearch to main search.  For this you will need the to use the &lt;STRONG&gt;return&lt;/STRONG&gt; command. By default &lt;STRONG&gt;return&lt;/STRONG&gt; only returns one value, but you can increase that.  There are performance implications to increases the return value.&lt;/P&gt;

&lt;P&gt;Here is my example not knowing your data. &lt;BR /&gt;
&lt;CODE&gt;&lt;/CODE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;BR /&gt;
index=myothersearchindex host="myserver*" [search index=mysearchindex host=myserver* My_Field="901089187"|return 10 MY_OTHER_FIELD]&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;What your search is accually looks like.&lt;BR /&gt;
&lt;CODE&gt;&lt;/CODE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;BR /&gt;
index=myothersearchindex host="myserver*" MY_OTHER_FIELD="Value1" OR MY_OTHER_FIELD="Value2" OR MY_OTHER_FIELD="Value3" OR MY_OTHER_FIELD="Value4" OR MY_OTHER_FIELD="Value5" OR MY_OTHER_FIELD="Value6"&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;If you just want the values use &lt;STRONG&gt;... | return 10 $MY_OTHER_FIELD&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Additional Reading:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.2/SearchReference/Return"&gt;Return&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps or gets you started.  If it does don't forget to vote up and/or accept the answer.&lt;/P&gt;

&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2013 16:56:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-in-search-command-not-returning-results/m-p/83552#M21283</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2013-04-03T16:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch in search command not returning results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-in-search-command-not-returning-results/m-p/83553#M21284</link>
      <description>&lt;P&gt;This is exactly what I was looking for, thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2013 18:29:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-in-search-command-not-returning-results/m-p/83553#M21284</guid>
      <dc:creator>msarro</dc:creator>
      <dc:date>2013-04-03T18:29:13Z</dc:date>
    </item>
  </channel>
</rss>

