<?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: Using Inputlookup to find a string contains a value and more in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-Inputlookup-to-find-a-string-contains-a-value-and-more/m-p/675024#M231014</link>
    <description>&lt;P&gt;Thanks for the sample. I opted to add a column "key" to my csv file, with wild card before and after the colorkey, (*blue*&amp;nbsp; for example) then add a lookup to the search after the inputlookup section.&amp;nbsp; &amp;nbsp; &amp;nbsp; | lookup keywords.csv key as "String1" output Key .&amp;nbsp; I'm not sure of the performance ramifications, I don't see any difference in run times.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jan 2024 12:30:12 GMT</pubDate>
    <dc:creator>73mustang</dc:creator>
    <dc:date>2024-01-22T12:30:12Z</dc:date>
    <item>
      <title>Using Inputlookup to find a string contains a value and more</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-Inputlookup-to-find-a-string-contains-a-value-and-more/m-p/674729#M230966</link>
      <description>&lt;P&gt;Hi guys, So heres&amp;nbsp; what im trying to do. I have a lookup csv with 3 columns. I have data with string values that might contain a value in my lookup. I have the basic setup working but i want to populate additional fields in my data set. Here is a very stripped down version of what i am doing.&amp;nbsp; First I have a basic lookup csv. It has &amp;nbsp;3 columns:&lt;/P&gt;
&lt;P&gt;active flagtype colorkey&lt;BR /&gt;yes sticker blue&lt;BR /&gt;yes tape red&lt;BR /&gt;no tape pink&lt;/P&gt;
&lt;P&gt;then my search which creates a couple test records looks like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| makeresults count=4
| streamstats count
| eval number = case(count=1, 25, count=2, 39, count=3, 31, count=4, null())
| eval string1 = case(count=1, "I like blue berries", count=3, "The sea is blue", count=2, "black is all colors", count=4, "Theredsunisredhot")
| table flagtype, flag, string1, ck
|search [ inputlookup templookup.csv
| eval string1 = "string1=" + "\"" + "*" + colorkey + "*" + "\""
| return 500 $string1
]
| eval flag = "KEYWORD FLAG"
| table flagtype, flag, string1, colorkey&lt;/LI-CODE&gt;
&lt;P&gt;my 4 column output results are:&lt;/P&gt;
&lt;P&gt;flagtype flag string1 colorkey&lt;BR /&gt;empty&amp;nbsp; &amp;nbsp;KEYWORD FLAG&amp;nbsp; &amp;nbsp;I like blue berries&amp;nbsp; &amp;nbsp; &amp;nbsp;empty&lt;BR /&gt;empty&amp;nbsp; &amp;nbsp;KEYWORD FLAG&amp;nbsp; &amp;nbsp;The sea is blue&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; empty&lt;BR /&gt;empty&amp;nbsp; &amp;nbsp;KEYWORD FLAG&amp;nbsp; &amp;nbsp;Theredsunisredhot empty&lt;/P&gt;
&lt;P&gt;How do&amp;nbsp; I populate the two empty columns using other columns in the lookup table.&lt;/P&gt;
&lt;P&gt;Thanks in advance for any help I can get.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jan 2024 09:03:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-Inputlookup-to-find-a-string-contains-a-value-and-more/m-p/674729#M230966</guid>
      <dc:creator>73mustang</dc:creator>
      <dc:date>2024-01-20T09:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using Inputlookup to find a string contains a value and more</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-Inputlookup-to-find-a-string-contains-a-value-and-more/m-p/674887#M230987</link>
      <description>&lt;P&gt;You cannot do this with simple event search as you attempted. &amp;nbsp;To add fields (sometimes called "enrichment"), you need to use &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Lookup" target="_blank" rel="noopener"&gt;lookup&lt;/A&gt; command. (Or join with inputlookup and sacrifice performance. &amp;nbsp;But this doesn't apply in your case.) &amp;nbsp;Your question is really about wanting to match a wildcard at the beginning of a key, which lookup does not support. &amp;nbsp;Given your sample data, you don't seem to have a real choice. &amp;nbsp;So, you will have to take some performance penalty and perform string matches yourself.&lt;/P&gt;&lt;P&gt;People (including myself) used to work around similar limitations in lookup with awkward mvzip-mvexpand-split sequences and the code is difficult to maintain. &amp;nbsp;Since 8.2, Splunk introduced a set of &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/JSONFunctions" target="_blank" rel="noopener"&gt;JSON functions&lt;/A&gt; that can represent data structure more expressively. &amp;nbsp;Here is one method:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=4
| streamstats count
| eval number = case(count=1, 25, count=2, 39, count=3, 31, count=4, null())
| eval string1 = case(count=1, "I like blue berries", count=3, "The sea is blue", count=2, "black is all colors", count=4, "Theredsunisredhot")
| table string1
| append
    [| inputlookup wildlookup.csv
| tojson output_field=wildlookup
| stats values(wildlookup) as wildlookup
| eval wild = json_object()
| foreach wildlookup mode=multivalue
    [ eval wild = json_set(wild, json_extract(&amp;lt;&amp;lt;ITEM&amp;gt;&amp;gt;, "colorkey"), &amp;lt;&amp;lt;ITEM&amp;gt;&amp;gt;)]
| fields wild]
| eventstats values(wild) as wild
| where isnotnull(string1)
| eval colors = json_keys(wild)
| foreach colors mode=json_array
    [eval colorkey = mvappend(colorkey, if(match(string1, &amp;lt;&amp;lt;ITEM&amp;gt;&amp;gt;), &amp;lt;&amp;lt;ITEM&amp;gt;&amp;gt;, null()))]
| mvexpand colorkey ``` in case of multiple matches ```
| foreach flagtype active
    [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = json_extract(json_extract(wild, colorkey), "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;")]
| eval flag = "KEYWORD FLAG"
| table flagtype, flag, string1, colorkey&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note I stripped fields that are irrelevant to the resultant table. &amp;nbsp;I also made provisions to protect possible multiple color matches. &amp;nbsp;The output is&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;flagtype&lt;/TD&gt;&lt;TD&gt;flag&lt;/TD&gt;&lt;TD&gt;string1&lt;/TD&gt;&lt;TD&gt;colorkey&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sticker&lt;/TD&gt;&lt;TD&gt;KEYWORD FLAG&lt;/TD&gt;&lt;TD&gt;I like blue berries&lt;/TD&gt;&lt;TD&gt;blue&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;KEYWORD FLAG&lt;/TD&gt;&lt;TD&gt;black is all colors&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sticker&lt;/TD&gt;&lt;TD&gt;KEYWORD FLAG&lt;/TD&gt;&lt;TD&gt;The sea is blue&lt;/TD&gt;&lt;TD&gt;blue&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;tape&lt;/TD&gt;&lt;TD&gt;KEYWORD FLAG&lt;/TD&gt;&lt;TD&gt;Theredsunisredhot&lt;/TD&gt;&lt;TD&gt;red&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2024 19:33:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-Inputlookup-to-find-a-string-contains-a-value-and-more/m-p/674887#M230987</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-01-19T19:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using Inputlookup to find a string contains a value and more</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-Inputlookup-to-find-a-string-contains-a-value-and-more/m-p/675024#M231014</link>
      <description>&lt;P&gt;Thanks for the sample. I opted to add a column "key" to my csv file, with wild card before and after the colorkey, (*blue*&amp;nbsp; for example) then add a lookup to the search after the inputlookup section.&amp;nbsp; &amp;nbsp; &amp;nbsp; | lookup keywords.csv key as "String1" output Key .&amp;nbsp; I'm not sure of the performance ramifications, I don't see any difference in run times.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 12:30:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-Inputlookup-to-find-a-string-contains-a-value-and-more/m-p/675024#M231014</guid>
      <dc:creator>73mustang</dc:creator>
      <dc:date>2024-01-22T12:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: Using Inputlookup to find a string contains a value and more</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-Inputlookup-to-find-a-string-contains-a-value-and-more/m-p/675104#M231024</link>
      <description>&lt;P&gt;If you don't observe performance degradation, you needn't worry about it.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 18:51:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-Inputlookup-to-find-a-string-contains-a-value-and-more/m-p/675104#M231024</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-01-22T18:51:22Z</dc:date>
    </item>
  </channel>
</rss>

