<?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: Joining and grouping indexes in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Joining-and-grouping-indexes/m-p/691283#M235405</link>
    <description>&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;completely different logic than in relational databases. It takes me a time to switch for this "new" one .&lt;/P&gt;&lt;P&gt;Ok, one more condition I noticed.&lt;BR /&gt;Two indexes are linked by field FieldA. The point is that FieldA in IndexB needs to be converted to :&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;| eval ModA = mvindex(split(FieldA, ","), 0)&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;So the relation one_to_many is IndexA.FieldA = IndexB.ModA&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;is this clear what I am writing about ... &lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jun 2024 11:17:43 GMT</pubDate>
    <dc:creator>kp_pl</dc:creator>
    <dc:date>2024-06-21T11:17:43Z</dc:date>
    <item>
      <title>Joining and grouping indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-and-grouping-indexes/m-p/690957#M235316</link>
      <description>&lt;P&gt;below is my scenario described by Oracle DBA &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have two indexes&lt;/P&gt;&lt;P&gt;INDEXA&lt;BR /&gt;fieldA&lt;BR /&gt;fieldB&lt;BR /&gt;fieldC&lt;/P&gt;&lt;P&gt;INDEXB&lt;BR /&gt;fieldA&lt;BR /&gt;fieldX&lt;BR /&gt;fieldY&lt;BR /&gt;fieldZ&lt;/P&gt;&lt;P&gt;First I need to join them both, it will be kind of LEFT JOIN as you porbably noticed by fieldA. Then group it by filedA+FieldZ and count each group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;In DBA language something like :&lt;BR /&gt;select a.fieldA, b.filedZ, count(*)&lt;BR /&gt;from indexA A left join indexB B on a.fieldA=b.fieldA&lt;BR /&gt;group by a.fieldA, b.filedZ&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any hints ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;K.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 06:51:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-and-grouping-indexes/m-p/690957#M235316</guid>
      <dc:creator>kp_pl</dc:creator>
      <dc:date>2024-06-18T06:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: Joining and grouping indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-and-grouping-indexes/m-p/690961#M235317</link>
      <description>&lt;P&gt;Usually, instead of using &lt;STRONG&gt;join,&lt;/STRONG&gt; you can replace it by &lt;STRONG&gt;stats&lt;/STRONG&gt; and will be a lot better in performance.&lt;/P&gt;&lt;P&gt;Try to do something like this and adjust it to your needs:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=INDEXA OR index=INDEXA
| stats values(fieldB) AS fieldB values(fieldC) AS fieldC  values(fieldX) AS fieldX values(fieldY) AS fieldY values(fieldZ) AS fieldZ by fieldA
| fillnull value=unknown fieldZ 
| stats count(fieldB) AS fieldB count(fieldC) AS fieldC  count(fieldX) AS fieldX count(fieldY) AS fieldY by fieldA, fieldZ &lt;/LI-CODE&gt;&lt;P&gt;First use OR to merge the info from both indexes and use stats to group the other fields by fieldA.&lt;/P&gt;&lt;P&gt;Then, assuming there will be gaps of information in some fiels, usa can use fillnull to fill those gaps.&lt;/P&gt;&lt;P&gt;Then, count all fields by fieldA and fieldZ.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also check this post:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.splunk.com/t5/Splunk-Search/Replace-join-with-stats-to-merge-events-based-on-common-field/m-p/321060" target="_blank"&gt;https://community.splunk.com/t5/Splunk-Search/Replace-join-with-stats-to-merge-events-based-on-common-field/m-p/321060&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 07:21:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-and-grouping-indexes/m-p/690961#M235317</guid>
      <dc:creator>glc_slash_it</dc:creator>
      <dc:date>2024-06-18T07:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: Joining and grouping indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-and-grouping-indexes/m-p/691283#M235405</link>
      <description>&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;completely different logic than in relational databases. It takes me a time to switch for this "new" one .&lt;/P&gt;&lt;P&gt;Ok, one more condition I noticed.&lt;BR /&gt;Two indexes are linked by field FieldA. The point is that FieldA in IndexB needs to be converted to :&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;| eval ModA = mvindex(split(FieldA, ","), 0)&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;So the relation one_to_many is IndexA.FieldA = IndexB.ModA&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;is this clear what I am writing about ... &lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2024 11:17:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-and-grouping-indexes/m-p/691283#M235405</guid>
      <dc:creator>kp_pl</dc:creator>
      <dc:date>2024-06-21T11:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: Joining and grouping indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-and-grouping-indexes/m-p/691284#M235406</link>
      <description>&lt;P&gt;Ok, to simplify it as easy as possible :&lt;/P&gt;&lt;P&gt;There are two indexes:&lt;BR /&gt;INDEXA&lt;BR /&gt;FieldA&lt;BR /&gt;FieldB&lt;/P&gt;&lt;P&gt;INDEXB&lt;BR /&gt;FieldA&lt;BR /&gt;FieldC&lt;/P&gt;&lt;P&gt;to create a relation between indexes I need to modify INDEXB.FieldA&lt;/P&gt;&lt;P&gt;&lt;EM&gt;eval FieldA1 = mvindex(split(FieldA, ","), 0)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;and now want to group by FieldA/FieldA1and FieldB and count FieldC&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2024 11:44:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-and-grouping-indexes/m-p/691284#M235406</guid>
      <dc:creator>kp_pl</dc:creator>
      <dc:date>2024-06-21T11:44:40Z</dc:date>
    </item>
  </channel>
</rss>

