<?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 How can I combine 2 searches consisting of inputlookup and outputlookups? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-combine-2-searches-consisting-of-inputlookup-and/m-p/364275#M107519</link>
    <description>&lt;P&gt;how can i combine queries to populate a lookup table?&lt;BR /&gt;
I have a lookup table with the following values&lt;/P&gt;

&lt;P&gt;item&lt;BR /&gt;&lt;BR /&gt;
1&lt;BR /&gt;
2&lt;BR /&gt;
3&lt;BR /&gt;
i'm using the splunk web framework to allow a user to insert  an item. if the user enters 3 then item 3 is changed to 4 and item 3 is inserted. the field input_item represents the value entered by the user. i'm using the query below to first renumber item 3 to 4 and to insert item 3 via an appended search. &lt;/P&gt;

&lt;P&gt;| inputlookup item.csv &lt;BR /&gt;
| eval input_item = 3&lt;BR /&gt;
| eval itemnumber = if(itemnumber &amp;gt;= input_item, itemnumber +1, itemnumber)&lt;BR /&gt;
| fields - input_item&lt;BR /&gt;
| outputlookup item.csv&lt;BR /&gt;
| append [&lt;BR /&gt;
| inputlookup item.csv | stats count as testcount&lt;BR /&gt;
| eval input_item =3&lt;BR /&gt;
| eval itemnumber = input_item&lt;BR /&gt;
| fields - testcount&lt;BR /&gt;
| outputlookup item.csv append=true]&lt;BR /&gt;
unfortunately, the  new item is created with a value of 4 instead of 3.&lt;BR /&gt;
is there  way to combine these two queries or do i need to create 2 separate queries via 2 separate searches in the search manager?&lt;/P&gt;

&lt;P&gt;thanks in advance,&lt;BR /&gt;
Peter&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 17:25:21 GMT</pubDate>
    <dc:creator>pc1234</dc:creator>
    <dc:date>2020-09-29T17:25:21Z</dc:date>
    <item>
      <title>How can I combine 2 searches consisting of inputlookup and outputlookups?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-combine-2-searches-consisting-of-inputlookup-and/m-p/364275#M107519</link>
      <description>&lt;P&gt;how can i combine queries to populate a lookup table?&lt;BR /&gt;
I have a lookup table with the following values&lt;/P&gt;

&lt;P&gt;item&lt;BR /&gt;&lt;BR /&gt;
1&lt;BR /&gt;
2&lt;BR /&gt;
3&lt;BR /&gt;
i'm using the splunk web framework to allow a user to insert  an item. if the user enters 3 then item 3 is changed to 4 and item 3 is inserted. the field input_item represents the value entered by the user. i'm using the query below to first renumber item 3 to 4 and to insert item 3 via an appended search. &lt;/P&gt;

&lt;P&gt;| inputlookup item.csv &lt;BR /&gt;
| eval input_item = 3&lt;BR /&gt;
| eval itemnumber = if(itemnumber &amp;gt;= input_item, itemnumber +1, itemnumber)&lt;BR /&gt;
| fields - input_item&lt;BR /&gt;
| outputlookup item.csv&lt;BR /&gt;
| append [&lt;BR /&gt;
| inputlookup item.csv | stats count as testcount&lt;BR /&gt;
| eval input_item =3&lt;BR /&gt;
| eval itemnumber = input_item&lt;BR /&gt;
| fields - testcount&lt;BR /&gt;
| outputlookup item.csv append=true]&lt;BR /&gt;
unfortunately, the  new item is created with a value of 4 instead of 3.&lt;BR /&gt;
is there  way to combine these two queries or do i need to create 2 separate queries via 2 separate searches in the search manager?&lt;/P&gt;

&lt;P&gt;thanks in advance,&lt;BR /&gt;
Peter&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:25:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-combine-2-searches-consisting-of-inputlookup-and/m-p/364275#M107519</guid>
      <dc:creator>pc1234</dc:creator>
      <dc:date>2020-09-29T17:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: How can I combine 2 searches consisting of inputlookup and outputlookups?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-combine-2-searches-consisting-of-inputlookup-and/m-p/364276#M107520</link>
      <description>&lt;P&gt;PC1234, looks like you just want to modify your CSV and add a row to it.  I am guessing that the csv gets evaluated once in the query, so try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup item.csv 
| eval input_item = 3
| eval itemnumber = if(itemnumber &amp;gt;= input_item, itemnumber +1, itemnumber)
| append [|makeresults | eval itemnumber = input_item | table itemnumber]
| fields - input_item
| outputlookup item.csv
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Dec 2017 13:32:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-combine-2-searches-consisting-of-inputlookup-and/m-p/364276#M107520</guid>
      <dc:creator>MonkeyK</dc:creator>
      <dc:date>2017-12-22T13:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: How can I combine 2 searches consisting of inputlookup and outputlookups?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-combine-2-searches-consisting-of-inputlookup-and/m-p/364277#M107521</link>
      <description>&lt;P&gt;FYI, I verified that the lookup is only loaded/evaluated when the search gets parsed by doing this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  makeresults
 |  eval data= "ITEM=1 ;ITEM=2; ITEM=3"
 |  makemv data delim=";"
 |  mvexpand data
 |  rename data as _raw  |  KV |  table ITEM | outputlookup items.csv | append [|inputlookup items.csv]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If the lookukp were processed for each reference, I would get two records each for ITEM=1, ITEM=2, ITEM=3&lt;BR /&gt;
Instead the results look like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ITEM
1
2
3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Run the same query again and I get:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ITEM
1
2
3
1
2
3
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Dec 2017 14:59:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-combine-2-searches-consisting-of-inputlookup-and/m-p/364277#M107521</guid>
      <dc:creator>MonkeyK</dc:creator>
      <dc:date>2017-12-22T14:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: How can I combine 2 searches consisting of inputlookup and outputlookups?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-combine-2-searches-consisting-of-inputlookup-and/m-p/364278#M107522</link>
      <description>&lt;P&gt;@pc1234 since you are anyways using Splunk Web Framework, this scenario seems to be a valid case for KV Store. So, you should try KV Store in place of Lookup: &lt;A href="http://dev.splunk.com/view/webframework-tutorials/SP-CAAAEZT"&gt;http://dev.splunk.com/view/webframework-tutorials/SP-CAAAEZT&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Dec 2017 17:55:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-combine-2-searches-consisting-of-inputlookup-and/m-p/364278#M107522</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-12-23T17:55:57Z</dc:date>
    </item>
  </channel>
</rss>

