<?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: How to join two searches, consider first and not second (subsearch)? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-consider-first-and-not-second-subsearch/m-p/462699#M130442</link>
    <description>&lt;P&gt;what if we place another join?&lt;BR /&gt;
     index=ABC sourcetype="perf" CLASS=PL| fields RR_ID USR_ID | dedup RR_ID&lt;BR /&gt;
           | join type=left RR_ID [search index=CAB sourcetype=CC | fields rrId| rename rrId AS RR_ID]    | join type=inner RR_ID [search index=CAB sourcetype=CC | fields rrId| rename rrId AS RR_ID]&lt;BR /&gt;
           | stats count by USR_ID&lt;/P&gt;

&lt;P&gt;Does the inner one show the common fields and the outer one show only fields from the first search?&lt;BR /&gt;
I have not tried but what I am expecting is this should give you 2 columns , first with only the first search and then with the common values, see if it is easy after this to exclude the RR_IDs which are present in both columns&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 01:56:42 GMT</pubDate>
    <dc:creator>Sukisen1981</dc:creator>
    <dc:date>2020-09-30T01:56:42Z</dc:date>
    <item>
      <title>How to join two searches, consider first and not second (subsearch)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-consider-first-and-not-second-subsearch/m-p/462698#M130441</link>
      <description>&lt;P&gt;I tried to use the NOT command to get the events from the first search but not in the second (subsearch) but in the results, I noticed events from the second search (subsearch). Is that a different way to do this search? I tried to use join type=left and the same issue occurred not bringing the events only regarding the first search not in the second search.&lt;/P&gt;

&lt;P&gt;with NOT:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ABC sourcetype="perf" CLASS=PL | fields RR_ID USR_ID | dedup RR_ID
    | table tblresult RR_ID USR_ID
    | search NOT[search index=CAB sourcetype=CC | fields rrId| rename rrId AS RR_ID| table tblresult RR_ID]
    | stats count by USR_ID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;with Left join:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ABC sourcetype="perf" CLASS=PL| fields RR_ID USR_ID | dedup RR_ID
      | join type=left RR_ID [search index=CAB sourcetype=CC | fields rrId| rename rrId AS RR_ID]
      | stats count by USR_ID
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Aug 2019 16:58:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-consider-first-and-not-second-subsearch/m-p/462698#M130441</guid>
      <dc:creator>rodrigobortolon</dc:creator>
      <dc:date>2019-08-27T16:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches, consider first and not second (subsearch)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-consider-first-and-not-second-subsearch/m-p/462699#M130442</link>
      <description>&lt;P&gt;what if we place another join?&lt;BR /&gt;
     index=ABC sourcetype="perf" CLASS=PL| fields RR_ID USR_ID | dedup RR_ID&lt;BR /&gt;
           | join type=left RR_ID [search index=CAB sourcetype=CC | fields rrId| rename rrId AS RR_ID]    | join type=inner RR_ID [search index=CAB sourcetype=CC | fields rrId| rename rrId AS RR_ID]&lt;BR /&gt;
           | stats count by USR_ID&lt;/P&gt;

&lt;P&gt;Does the inner one show the common fields and the outer one show only fields from the first search?&lt;BR /&gt;
I have not tried but what I am expecting is this should give you 2 columns , first with only the first search and then with the common values, see if it is easy after this to exclude the RR_IDs which are present in both columns&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:56:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-consider-first-and-not-second-subsearch/m-p/462699#M130442</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2020-09-30T01:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches, consider first and not second (subsearch)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-consider-first-and-not-second-subsearch/m-p/462700#M130443</link>
      <description>&lt;P&gt;Hi Sukisen1981! Thank you for your reply. I implemented here and apparently works well but I split the searchs to understand why I need to use a new join (inner) after the left join. I thought that the left join will bring only the results in first search not in the second but brings me everything. The query whitout the join inner I try to bring the columns from first search and second but as the reference column is RR_ID, could I rename and bring in distinct columns to check that in the second search I will have values and other raws with no value? &lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 14:41:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-consider-first-and-not-second-subsearch/m-p/462700#M130443</guid>
      <dc:creator>rodrigobortolon</dc:creator>
      <dc:date>2019-08-29T14:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches, consider first and not second (subsearch)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-consider-first-and-not-second-subsearch/m-p/462701#M130444</link>
      <description>&lt;P&gt;hi @rodrigobortolon &lt;BR /&gt;
No, the left join does not do what you think, please refer to the documentation (the venn diagrams) here -&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/Join"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/Join&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;A left join gives (to use set notation) B complement + A intersection B = Theoretically A , since B complement is nothing but all values of A, except A intersection B and we of course ADD  A intersection B to that=Unique values of A + common values&lt;BR /&gt;
An Inner join gives only A intersection B.&lt;BR /&gt;
So when your first left join gets performed, what you get is ALL values of the first index AND no unique values from the second.&lt;BR /&gt;
when your second join gets performed you get ONLY values unique to both A&amp;amp;B (A intersection B).&lt;BR /&gt;
So my idea was if you can remove those RR_IDs AFTER performing both the joins which are common to both AND WILL BE PRESENT in the output of the first, left join  - you got to be left with only values UNIQUE to to the first index...&lt;BR /&gt;
And yes - you can rename the rrID in the second, inner join just like you did&lt;BR /&gt;
This problem can also be solved with stats, but I don't want to go down that route for two reasons - I feel you are near the solution  + your 'join' fundas are getting unjoined and all clear : )&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 16:22:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-consider-first-and-not-second-subsearch/m-p/462701#M130444</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-29T16:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches, consider first and not second (subsearch)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-consider-first-and-not-second-subsearch/m-p/462702#M130445</link>
      <description>&lt;P&gt;Your 1st search was nearly there I believe:&lt;BR /&gt;
Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ABC sourcetype="perf" CLASS=PL NOT [search index=CAB sourcetype=CC | fields rrId| rename rrId AS RR_ID| fields RR_ID]
| dedup RR_ID
| stats count by USR_ID
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Aug 2019 16:54:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-consider-first-and-not-second-subsearch/m-p/462702#M130445</guid>
      <dc:creator>diogofgm</dc:creator>
      <dc:date>2019-08-29T16:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches, consider first and not second (subsearch)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-consider-first-and-not-second-subsearch/m-p/462703#M130446</link>
      <description>&lt;P&gt;@Sukisen1981 , thank you again for our reply! So let me get if I understand. This part (original from my question) &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ABC sourcetype="perf" CLASS=PL| fields RR_ID USR_ID | dedup RR_ID
| join type=left RR_ID [search index=CAB sourcetype=CC | fields rrId| rename rrId AS RR_ID]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;will bring me ALL values of the first index AND no unique values from the second, correct?&lt;BR /&gt;
The second join that you mentioned "when your second join gets performed you get ONLY values unique to both A&amp;amp;B (A intersection B).", you mean with this additional part (join type=inner) after the left join?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ABC sourcetype="perf" CLASS=PL| fields RR_ID USR_ID | dedup RR_ID
| join type=left RR_ID [search index=CAB sourcetype=CC | fields rrId| rename rrId AS RR_ID] | join type=inner RR_ID [search index=CAB sourcetype=CC | fields rrId| rename rrId AS RR_ID]
| stats count by USR_ID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am still in this part thinking that with this additional join I will get as you mention the A intersection B, not the final part that you mentioned with only the left (join left results). &lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 13:28:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-consider-first-and-not-second-subsearch/m-p/462703#M130446</guid>
      <dc:creator>rodrigobortolon</dc:creator>
      <dc:date>2019-08-30T13:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches, consider first and not second (subsearch)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-consider-first-and-not-second-subsearch/m-p/462704#M130447</link>
      <description>&lt;P&gt;Hi @diogofgm , this approach didn't work for me. It brings the values from second one as well. I am trying to check the first approach with left join and inner join that @Sukisen1981 provide us here. Anyway, thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 14:00:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-consider-first-and-not-second-subsearch/m-p/462704#M130447</guid>
      <dc:creator>rodrigobortolon</dc:creator>
      <dc:date>2019-08-30T14:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two searches, consider first and not second (subsearch)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-consider-first-and-not-second-subsearch/m-p/462705#M130448</link>
      <description>&lt;P&gt;hi @rodrigobortolon &lt;BR /&gt;
You are correct,&lt;BR /&gt;
I suggest running the 2 joins separately first and validating that we get all events from the first index(including common events in both indexes) for the left join and then validating that we only receive A intersection B events from the inner join&lt;BR /&gt;
If this works, can you then run the whole query as it is and confirm how the result looks like?&lt;BR /&gt;
It might be worthwhile to rename as follows:&lt;BR /&gt;
left join - same as it is&lt;BR /&gt;
inner join - rename first rrid from main query as something else, rrd_1 and also use the same field rename in inner join&lt;BR /&gt;
PS- Do you have access to _audit and _internal indexes? I am struggling a bit to better visualize the requirement, and we can kind of perhaps mock this scenario using those 2 indexes&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 14:47:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-two-searches-consider-first-and-not-second-subsearch/m-p/462705#M130448</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-30T14:47:25Z</dc:date>
    </item>
  </channel>
</rss>

