<?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: Join only returns 1 value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Join-only-returns-1-value/m-p/480389#M192989</link>
    <description>&lt;P&gt;Ah shoot sorry, i've edited the post look again. &lt;/P&gt;</description>
    <pubDate>Fri, 28 Feb 2020 14:36:43 GMT</pubDate>
    <dc:creator>arrowecssupport</dc:creator>
    <dc:date>2020-02-28T14:36:43Z</dc:date>
    <item>
      <title>Join only returns 1 value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-only-returns-1-value/m-p/480387#M192987</link>
      <description>&lt;P&gt;The search below looks up a serial number in another index, there will be multiple values to "x", but currently it only returns 1.&lt;BR /&gt;
How do I get it to return all of the values? &lt;BR /&gt;
Also, 2nd question, as it's only returning 1 value, how does it choose which value to return?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = email
serialnumber=123456789
| join serialnumber type=left  [ search index=db  | dedup Y | rename serial AS serialnumber ]
| table serialnumber  X
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Feb 2020 14:25:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-only-returns-1-value/m-p/480387#M192987</guid>
      <dc:creator>arrowecssupport</dc:creator>
      <dc:date>2020-02-28T14:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: Join only returns 1 value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-only-returns-1-value/m-p/480388#M192988</link>
      <description>&lt;P&gt;Hi @arrowecssupport &lt;/P&gt;

&lt;P&gt;I am making some assumptions about where the "single value" is coming from, but lets talk about dedup first.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;dedup x&lt;/CODE&gt; means 'deduplicate x'&lt;BR /&gt;
This has the effect of only returning unique values of x.&lt;/P&gt;

&lt;P&gt;given values like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;serial x
----------
123  foo
456  bar
789  bar
012  baz
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you would see one entry for each value of foo, bar, baz.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;serial x
----------
123  foo
456  bar
012  baz
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Your second question "how does it choose" - it will pick the most recent (last) entry in the set of results.&lt;/P&gt;

&lt;P&gt;That does not always mean the latest (or last by time), which is why the sort order is important.&lt;BR /&gt;
If you want it to be the latest by _time you should &lt;CODE&gt;|sort - _time&lt;/CODE&gt; before you &lt;CODE&gt;|dedup x&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The last part of the puzzle is the &lt;CODE&gt;join&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;join by default only matches 1 entry. It also chooses the 'last in the result set' &lt;BR /&gt;
For the join to return more than one value, you need to specify how many.&lt;BR /&gt;
&lt;CODE&gt;|join max=&amp;lt;int&amp;gt;&lt;/CODE&gt; or use 0 to return all values.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 14:33:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-only-returns-1-value/m-p/480388#M192988</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2020-02-28T14:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: Join only returns 1 value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-only-returns-1-value/m-p/480389#M192989</link>
      <description>&lt;P&gt;Ah shoot sorry, i've edited the post look again. &lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 14:36:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-only-returns-1-value/m-p/480389#M192989</guid>
      <dc:creator>arrowecssupport</dc:creator>
      <dc:date>2020-02-28T14:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: Join only returns 1 value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-only-returns-1-value/m-p/480390#M192990</link>
      <description>&lt;P&gt;Ok, thats thrown me a bit, but if I understand and my last edit on the join command follows the same logic as your question, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = email
 serialnumber=123456789
 | join serialnumber max=0 type=left  [ search index=db  | dedup Y | rename serial AS serialnumber ]
 | table serialnumber  X
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Feb 2020 14:40:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-only-returns-1-value/m-p/480390#M192990</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2020-02-28T14:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: Join only returns 1 value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-only-returns-1-value/m-p/480391#M192991</link>
      <description>&lt;P&gt;FYI i just updated your question title - Its not a subsearch, its the join that is causing it. Hopefully my suggestion above works!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 15:12:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-only-returns-1-value/m-p/480391#M192991</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2020-02-28T15:12:38Z</dc:date>
    </item>
  </channel>
</rss>

