<?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 Subsearch not returning any results though matches exists. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-not-returning-any-results-though-matches-exists/m-p/268723#M189959</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;
I am trying to run below query and the scenario is here. This is not returning any results though match exists. Can you help me?&lt;BR /&gt;
1)  My subsearch yields multiple order numbers from file 1.&lt;BR /&gt;
2) I need to pass this list to another file, file 2 which contains super set of the order numbers resulted in my subsearch.&lt;/P&gt;

&lt;P&gt;I want to fetch all the events which has orderNo from file 1 that are resulted in file 2.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;source="dir1/file1.log"&lt;/EM&gt;&lt;/STRONG&gt;  &lt;STRONG&gt;[ search host="server1" source="dir2/file2.log"  | rex field=_raw "\"orderNo\":\"(?\w*-\w*-\w*-\w*-\w*)" | stats count by orderNo | table orderNumbers | format  ]&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I tried several variations of passing the sub search results (table, list, etc) to main search but not working. Can you please identify what is wrong here?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 09:15:24 GMT</pubDate>
    <dc:creator>sk_subhani</dc:creator>
    <dc:date>2020-09-29T09:15:24Z</dc:date>
    <item>
      <title>Subsearch not returning any results though matches exists.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-not-returning-any-results-though-matches-exists/m-p/268723#M189959</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I am trying to run below query and the scenario is here. This is not returning any results though match exists. Can you help me?&lt;BR /&gt;
1)  My subsearch yields multiple order numbers from file 1.&lt;BR /&gt;
2) I need to pass this list to another file, file 2 which contains super set of the order numbers resulted in my subsearch.&lt;/P&gt;

&lt;P&gt;I want to fetch all the events which has orderNo from file 1 that are resulted in file 2.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;source="dir1/file1.log"&lt;/EM&gt;&lt;/STRONG&gt;  &lt;STRONG&gt;[ search host="server1" source="dir2/file2.log"  | rex field=_raw "\"orderNo\":\"(?\w*-\w*-\w*-\w*-\w*)" | stats count by orderNo | table orderNumbers | format  ]&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I tried several variations of passing the sub search results (table, list, etc) to main search but not working. Can you please identify what is wrong here?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:15:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-not-returning-any-results-though-matches-exists/m-p/268723#M189959</guid>
      <dc:creator>sk_subhani</dc:creator>
      <dc:date>2020-09-29T09:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch not returning any results though matches exists.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-not-returning-any-results-though-matches-exists/m-p/268724#M189960</link>
      <description>&lt;P&gt;Hello sk_subhani,&lt;/P&gt;

&lt;P&gt;About this search...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  source="dir1/file1.log" [ search host="server1" source="dir2/file2.log" | rex field=_raw "\"orderNo\"\:\"(?\w*-\w*-\w*-\w*-\w*)" | stats count by orderNo | table orderNumbers | format ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When you do &lt;CODE&gt;stats count by orderNo&lt;/CODE&gt; you're left with 1 field called orderNo which equals the count.  Then you're sending this one field into a &lt;CODE&gt;table orderNumbers&lt;/CODE&gt; which doesnt exist.  So you get 0 results.&lt;/P&gt;

&lt;P&gt;If you will supply us with some sample data from both files we can help you write the correct search.&lt;/P&gt;

&lt;P&gt;Just to give you example... you can try this but I'm making many assumptions and dont believe this search will be a sure answer:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; source="dir1/file1.log" 
 | eval orderNo=orderNumbers 
 | join orderNo [search host="server1" source="dir2/file2.log" | rex field=_raw "\"orderNo\"\:\"(?\w*-\w*-\w*-\w*-\w*)" | stats count by orderNo] 
 | table orderNumbers orderNo
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Mar 2016 13:44:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-not-returning-any-results-though-matches-exists/m-p/268724#M189960</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-03-28T13:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch not returning any results though matches exists.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-not-returning-any-results-though-matches-exists/m-p/268725#M189961</link>
      <description>&lt;P&gt;Assuming the 2 datasets have the same format and that field &lt;CODE&gt;orderNo&lt;/CODE&gt; does not exist and must be created, this should work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="dir1/file1.log" OR (host="server1" source="dir2/file2.log") | rex "\"orderNo\"\:\"(?&amp;lt;orderNo&amp;gt;\w*-\w*-\w*-\w*-\w*)"  | stats dc(source) AS numSources values(*) AS * by orderNo | where  numSources&amp;gt;1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In your case you can (AND ALWAYS SHOULD if you can) avoid using &lt;CODE&gt;join&lt;/CODE&gt; and &lt;CODE&gt;subsearches&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2016 08:50:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-not-returning-any-results-though-matches-exists/m-p/268725#M189961</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-03-29T08:50:34Z</dc:date>
    </item>
  </channel>
</rss>

