<?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: Foreign key in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Foreign-key/m-p/367331#M108359</link>
    <description>&lt;P&gt;Hi yurykiselev,&lt;BR /&gt;
there are many choices: join, transaction o stats:&lt;BR /&gt;
join&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=examination
| rename user_id AS id_name
| join id_name type=left [ search index=patients | fields id_name gender date_of_birth ]
| table _time user_id gender date_of_birth exam_type 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transaction &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=examination OR  index=patients
| rename user_id AS id_name
| transaction id_name 
| table _time user_id gender date_of_birth exam_type 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;stats&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=examination OR  index=patients
| rename user_id AS id_name
| stats values(gender) AS gender values(date_of_birth) As date_of_birth values(exam_type) AS exam_type by user_id 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Stats is the quickest.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Wed, 21 Jun 2017 09:55:59 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2017-06-21T09:55:59Z</dc:date>
    <item>
      <title>Foreign key</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Foreign-key/m-p/367330#M108358</link>
      <description>&lt;P&gt;Hi!&lt;BR /&gt;
I have two indexes: patients and examination&lt;/P&gt;

&lt;P&gt;patients: &lt;EM&gt;| id name | gender | date_of_birth |&lt;/EM&gt;&lt;BR /&gt;
examination: &lt;EM&gt;| user_id | exam_type |&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;How could I get a table of all examinations for males?&lt;BR /&gt;
Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:37:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Foreign-key/m-p/367330#M108358</guid>
      <dc:creator>yurykiselev</dc:creator>
      <dc:date>2020-09-29T14:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: Foreign key</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Foreign-key/m-p/367331#M108359</link>
      <description>&lt;P&gt;Hi yurykiselev,&lt;BR /&gt;
there are many choices: join, transaction o stats:&lt;BR /&gt;
join&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=examination
| rename user_id AS id_name
| join id_name type=left [ search index=patients | fields id_name gender date_of_birth ]
| table _time user_id gender date_of_birth exam_type 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transaction &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=examination OR  index=patients
| rename user_id AS id_name
| transaction id_name 
| table _time user_id gender date_of_birth exam_type 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;stats&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=examination OR  index=patients
| rename user_id AS id_name
| stats values(gender) AS gender values(date_of_birth) As date_of_birth values(exam_type) AS exam_type by user_id 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Stats is the quickest.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 09:55:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Foreign-key/m-p/367331#M108359</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-06-21T09:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Foreign key</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Foreign-key/m-p/367332#M108360</link>
      <description>&lt;P&gt;Is id_name the foreign key? i.e. can we correlate id_name and user_id?&lt;/P&gt;

&lt;P&gt;If so you can create a field alias in one of the indexes to be the same as that in the  other which is similar to, &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rename id_name as user_id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: Once you create Field Alias you will not need rename command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=patient AND id_name=* gender="male") OR (index=examination AND user_id=*)
| rename id_name as user_id
| stats values(examination) as examinations by user_id
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:33:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Foreign-key/m-p/367332#M108360</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T14:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: Foreign key</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Foreign-key/m-p/367333#M108361</link>
      <description>&lt;P&gt;Thank you all!&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 19:26:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Foreign-key/m-p/367333#M108361</guid>
      <dc:creator>yurykiselev</dc:creator>
      <dc:date>2017-06-21T19:26:43Z</dc:date>
    </item>
  </channel>
</rss>

