<?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: Why does lookup return null when there are multiple matches? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-does-lookup-return-null-when-there-are-multiple-matches/m-p/631450#M219318</link>
    <description>&lt;P&gt;Thanks for the diagnostic sequence, &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;. &amp;nbsp;As I try to implement, I realized two things. &amp;nbsp;First, I didn't record the real-world QID in the original problem statement, even if the statement was precise. &amp;nbsp;Now I have doubts about the precision because if I filter down to a single QID, I haven't found one that can trigger a blank return.&lt;/P&gt;&lt;P&gt;Second, I notice that even with makeresults, I can construct a group of QIDs to trigger this behavior. (The behavior seems to be the same as the group of QIDs appear in an index search.) &amp;nbsp;For example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time
| eval QID = split("257210,257212,257100", ",")
| mvexpand QID
| lookup mylookup QID output Detected&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=myindex QID IN ("257210","257212","257100")
| stats count by QID
| lookup mylookup QID output Detected&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;both return something like&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;QID&lt;/TD&gt;&lt;TD&gt;Detected&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;257210&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;257212&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;257100&lt;/TD&gt;&lt;TD&gt;&lt;SPAN&gt;2022-12-10&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2023-01-01&lt;/SPAN&gt;&lt;BR /&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Within this group, which one returns null and which real values do not change no matter the order of QIDs. &amp;nbsp;If I search individual ones, each of them has non-null return.&lt;/P&gt;&lt;P&gt;In short, I couldn't reproduce a difference between simulated QID and real-world QID. &amp;nbsp;The difference seems to be whether a group of events contain different QIDs or just a single QID.&lt;/P&gt;&lt;P&gt;How can I diagnose this further?&lt;/P&gt;</description>
    <pubDate>Sun, 19 Feb 2023 06:40:56 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2023-02-19T06:40:56Z</dc:date>
    <item>
      <title>Why does lookup return null when there are multiple matches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-lookup-return-null-when-there-are-multiple-matches/m-p/631064#M219197</link>
      <description>&lt;P&gt;I have a lookup with multiple columns (keys). &amp;nbsp;Some combinations make a unique match, but I need an ambiguous search on a single key to return all matched items of a particular field. &amp;nbsp;In a simplified form, the lookup is like this&lt;/P&gt;
&lt;TABLE border="1" width="82.57575757575758%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="13.610879436567512%"&gt;QID&lt;/TD&gt;
&lt;TD width="28.74386062459457%"&gt;IP&lt;/TD&gt;
&lt;TD width="40.2210175145955%"&gt;Detected&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="13.610879436567512%"&gt;12345&lt;/TD&gt;
&lt;TD width="28.74386062459457%"&gt;127.0.0.1&lt;/TD&gt;
&lt;TD width="40.2210175145955%"&gt;2022-12-10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="13.610879436567512%"&gt;45678&lt;/TD&gt;
&lt;TD width="28.74386062459457%"&gt;127.0.0.1&lt;/TD&gt;
&lt;TD width="40.2210175145955%"&gt;2023-01-21&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="13.610879436567512%"&gt;12345&lt;/TD&gt;
&lt;TD width="28.74386062459457%"&gt;127.0.0.2&lt;/TD&gt;
&lt;TD width="40.2210175145955%"&gt;2023-01-01&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="13.610879436567512%"&gt;45678&lt;/TD&gt;
&lt;TD width="28.74386062459457%"&gt;127.0.0.2&lt;/TD&gt;
&lt;TD width="40.2210175145955%"&gt;2022-12-15&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="13.610879436567512%"&gt;23456&lt;/TD&gt;
&lt;TD width="28.74386062459457%"&gt;...&lt;/TD&gt;
&lt;TD width="40.2210175145955%"&gt;...&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;QID and IP determines a unique Detected value; you can say the combination is a primary key. &amp;nbsp;No problem with search by primary key. &amp;nbsp;My requirement is to search by QID alone. &amp;nbsp;For 12345, for example, I expect the return to be multivalued (2022-12-10,&amp;nbsp;2023-01-01).&lt;/P&gt;
&lt;P&gt;If I hard code QID in an emulation, that's exactly what I get.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| makeresults
| eval QID=12345
| lookup mylookup QID
| table QID Detected&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will give me&lt;/P&gt;
&lt;TABLE border="1" width="38.504182449494955%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="15.73770491803279%"&gt;QID&lt;/TD&gt;
&lt;TD width="22.768694822977068%"&gt;Detected&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="15.73770491803279%"&gt;12345&lt;/TD&gt;
&lt;TD width="22.768694822977068%"&gt;
&lt;P&gt;2022-12-10&lt;BR /&gt;2023-01-01&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;But if use the same lookup in a search, e.g.,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=myindex QID=12345
| stats count by QID ``` result is the same whether or not stats precedes lookup ```
| lookup mylookup QID
| table QID Detected&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the result is blank&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="15.73770491803279%"&gt;QID&lt;/TD&gt;
&lt;TD width="22.768694822977068%"&gt;Detected&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="15.73770491803279%"&gt;12345&lt;/TD&gt;
&lt;TD width="22.768694822977068%"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;The behavior can be more complex if the search returns more than one QID (e.g., &lt;FONT face="andale mono,times"&gt;QID IN (12345, 45678)&lt;/FONT&gt;). &amp;nbsp;Sometimes one of them will get Detected populated, but not others.&lt;/P&gt;
&lt;P&gt;How can I make sure multiple matches are all returned?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 20:58:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-lookup-return-null-when-there-are-multiple-matches/m-p/631064#M219197</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-02-15T20:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Why does lookup return null when there are multiple matches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-lookup-return-null-when-there-are-multiple-matches/m-p/631083#M219210</link>
      <description>&lt;P&gt;As your makeresults example shows, you should get both results, so it points to something different about the true value of QID in the index=myindex case.&lt;/P&gt;&lt;P&gt;If you add the following after stats count for a bit of diagnostics&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval len=len(QID)
| eval Q=12345
| lookup mylookup QID OUTPUT Detected as D_1
| lookup mylookup QID as Q OUTPUT Detected as D_2
| eval match=if(QID=Q, "true", "false")
| table count QID len Q match D_*&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;what do you get?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 22:20:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-lookup-return-null-when-there-are-multiple-matches/m-p/631083#M219210</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-02-15T22:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: Why does lookup return null when there are multiple matches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-lookup-return-null-when-there-are-multiple-matches/m-p/631450#M219318</link>
      <description>&lt;P&gt;Thanks for the diagnostic sequence, &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;. &amp;nbsp;As I try to implement, I realized two things. &amp;nbsp;First, I didn't record the real-world QID in the original problem statement, even if the statement was precise. &amp;nbsp;Now I have doubts about the precision because if I filter down to a single QID, I haven't found one that can trigger a blank return.&lt;/P&gt;&lt;P&gt;Second, I notice that even with makeresults, I can construct a group of QIDs to trigger this behavior. (The behavior seems to be the same as the group of QIDs appear in an index search.) &amp;nbsp;For example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time
| eval QID = split("257210,257212,257100", ",")
| mvexpand QID
| lookup mylookup QID output Detected&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=myindex QID IN ("257210","257212","257100")
| stats count by QID
| lookup mylookup QID output Detected&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;both return something like&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;QID&lt;/TD&gt;&lt;TD&gt;Detected&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;257210&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;257212&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;257100&lt;/TD&gt;&lt;TD&gt;&lt;SPAN&gt;2022-12-10&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2023-01-01&lt;/SPAN&gt;&lt;BR /&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Within this group, which one returns null and which real values do not change no matter the order of QIDs. &amp;nbsp;If I search individual ones, each of them has non-null return.&lt;/P&gt;&lt;P&gt;In short, I couldn't reproduce a difference between simulated QID and real-world QID. &amp;nbsp;The difference seems to be whether a group of events contain different QIDs or just a single QID.&lt;/P&gt;&lt;P&gt;How can I diagnose this further?&lt;/P&gt;</description>
      <pubDate>Sun, 19 Feb 2023 06:40:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-lookup-return-null-when-there-are-multiple-matches/m-p/631450#M219318</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-02-19T06:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Why does lookup return null when there are multiple matches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-lookup-return-null-when-there-are-multiple-matches/m-p/631495#M219332</link>
      <description>&lt;P&gt;Is it KV store or CSV - if CSV is mylookup a definition or the CSV directly. If the definition, remove the layer of abstraction and try CSV. If KV store, try writing to the CSV and trying CSV.&lt;/P&gt;&lt;P&gt;Try making it a wildcard(QID) in the definition and adding for a couple of the failing examples, the ** around the QID.&lt;/P&gt;&lt;P&gt;Is it always the case that one of the QID Detected outputs is MV, as in your example? If so, disable one of the entries in the lookup. If it's a definition, set it to return 1 max result to see if that then causes the others to populate.&lt;/P&gt;&lt;P&gt;Just stabbing in the dark here to see what gives...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Feb 2023 22:59:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-lookup-return-null-when-there-are-multiple-matches/m-p/631495#M219332</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-02-19T22:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why does lookup return null when there are multiple matches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-lookup-return-null-when-there-are-multiple-matches/m-p/631498#M219335</link>
      <description>&lt;P&gt;This is CSV with definition. &amp;nbsp;I didn't even know that you can use CSV directly. &amp;nbsp;So I tried. &amp;nbsp;It made no difference. &amp;nbsp;I then redefined QID's match type to wildcard. &amp;nbsp;It also made no difference; if I surround any test value with **, no value can return because the entries themselves do not have wildcard characters.&lt;/P&gt;&lt;P&gt;The third test, unfortunately also doesn't give me additional info. &amp;nbsp;I use the following as a basic test&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup mylookup
| stats count by QID
| lookup mylookup QID
| where isnull(Detected)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Somewhat to my surprise, there are many null outputs with count of 1. (Also, because how many QIDs are in search events is known to make a difference in which QIDs return null, I cannot say that the above test is definitive. &amp;nbsp;It only shows that it is possible for single-entries to return null.)&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 02:21:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-lookup-return-null-when-there-are-multiple-matches/m-p/631498#M219335</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-02-20T02:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Why does lookup return null when there are multiple matches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-lookup-return-null-when-there-are-multiple-matches/m-p/631501#M219337</link>
      <description>&lt;P&gt;For the wildcard definition, it is the CSV version that needs the **, not the data itself, so the lookup should contain&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;*257210*&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and the data has&amp;nbsp;257210 - just in case there was something odd.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can you DM me your lookup - as I can't reproduce it&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 02:50:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-lookup-return-null-when-there-are-multiple-matches/m-p/631501#M219337</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-02-20T02:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why does lookup return null when there are multiple matches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-lookup-return-null-when-there-are-multiple-matches/m-p/631946#M219499</link>
      <description>&lt;P&gt;It looks like it's related to the size of the lookup, which exceeds&amp;nbsp;max_memtable_bytes (default 25MB) and there is a memory issue, which can give somewhat random results.&lt;/P&gt;&lt;P&gt;When a lookup exceeds that value, Splunk uses an indexing mechanism to access the lookup, but it seems that does not work properly.&lt;/P&gt;&lt;DIV class=""&gt;If you increase max_memtable_bytes in limits.conf to a size larger than your lookup, the problem goes away, e.g. doubling it to 50MB&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[lookup]
max_memtable_bytes = 52428800&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 03:26:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-lookup-return-null-when-there-are-multiple-matches/m-p/631946#M219499</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-02-23T03:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Why does lookup return null when there are multiple matches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-lookup-return-null-when-there-are-multiple-matches/m-p/631972#M219508</link>
      <description>&lt;P&gt;Thank you so much,&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;! &amp;nbsp;This had been bugging me for years. &amp;nbsp;Given the unpredictability, I should have suspected a memory-related problem.&lt;/P&gt;&lt;P&gt;So, there seems to be two separate problems. &amp;nbsp;One is that index mechanism (mylookup.csv_XXXXX.idx) is not performing as designed. &amp;nbsp;The second problem is the lack of any indication in splunkd.log that suggests&amp;nbsp;&lt;SPAN&gt;max_memtable_bytes might be exceeded.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 08:09:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-lookup-return-null-when-there-are-multiple-matches/m-p/631972#M219508</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-02-23T08:09:45Z</dc:date>
    </item>
  </channel>
</rss>

