<?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: How to fit a subsearch in the middle of a search query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294469#M160391</link>
    <description>&lt;P&gt;So the $drop_name$ and $test_name are the user input tokens (dropdown or textbox I'm guessing)? Why do you need a subsearch for that if you just want user to filter records based on their inputs.. Something like this should work just fine. (assuming $drop_name$ gives you column name (index/sourcetype/description) and $text_name$ gives the values to be searched)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup sourcetypes_raw.csv | lookup sourcetype_lookup.csv sourcetype OUTPUT description
| where '$drop_name$'="$text_name$" AND match(description,"$text_name$")
| mvcombine sourcetype | sort index | table index sourcetype description
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 Sep 2020 14:45:21 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2020-09-29T14:45:21Z</dc:date>
    <item>
      <title>How to fit a subsearch in the middle of a search query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294466#M160388</link>
      <description>&lt;P&gt;Hi everyone.  How do I format this subsearch to work in my search query?  I'm still fairly new to splunk&lt;/P&gt;

&lt;PRE&gt;
| inputlookup sourcetypes_raw.csv | lookup sourcetype_lookup.csv sourcetype OUTPUT description | search "$drop_name$"="$text_name$*" [search "$drop_name$"="*$text_name$*" | where $drop_name$==description] | mvcombine sourcetype | sort index | table index sourcetype description
&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Jul 2017 20:00:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294466#M160388</guid>
      <dc:creator>chaninphx</dc:creator>
      <dc:date>2017-07-03T20:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to fit a subsearch in the middle of a search query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294467#M160389</link>
      <description>&lt;P&gt;What is your requirement here? Could you provide details on different data sources you're using and available fields and relationship between them? &lt;/P&gt;</description>
      <pubDate>Mon, 03 Jul 2017 20:08:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294467#M160389</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-07-03T20:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to fit a subsearch in the middle of a search query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294468#M160390</link>
      <description>&lt;P&gt;I'm using two csv files that link three fields together, the index, the sourcetypes from that index, and the description of those sourcetypes.  I'm creating an app where you can search and find data for all three fields.  However when the user selects that they want to find the description, I want it to find where description="&lt;EM&gt;$text_name$&lt;/EM&gt;" instead of "$text_name$*" so it can be easier for the user to find the sourcetype that goes with their description if they only use one word to describe it.  &lt;/P&gt;</description>
      <pubDate>Mon, 03 Jul 2017 20:21:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294468#M160390</guid>
      <dc:creator>chaninphx</dc:creator>
      <dc:date>2017-07-03T20:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to fit a subsearch in the middle of a search query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294469#M160391</link>
      <description>&lt;P&gt;So the $drop_name$ and $test_name are the user input tokens (dropdown or textbox I'm guessing)? Why do you need a subsearch for that if you just want user to filter records based on their inputs.. Something like this should work just fine. (assuming $drop_name$ gives you column name (index/sourcetype/description) and $text_name$ gives the values to be searched)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup sourcetypes_raw.csv | lookup sourcetype_lookup.csv sourcetype OUTPUT description
| where '$drop_name$'="$text_name$" AND match(description,"$text_name$")
| mvcombine sourcetype | sort index | table index sourcetype description
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:45:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294469#M160391</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-29T14:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to fit a subsearch in the middle of a search query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294470#M160392</link>
      <description>&lt;P&gt;Thanks for your response somesoni2.  So what I want to do is if $drop_name$ turns out to be index or sourcetype then i want the search to be $drop_name$="$text_name$&lt;EM&gt;". If it turns out that the user chose description for $drop_name$, I want it to search $drop_name$="&lt;/EM&gt;$text_name$*".  Hopefully it makes a little more sense.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:45:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294470#M160392</guid>
      <dc:creator>chaninphx</dc:creator>
      <dc:date>2020-09-29T14:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to fit a subsearch in the middle of a search query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294471#M160393</link>
      <description>&lt;P&gt;Sorry i dont know why it won't put the wildcards in there but there should be one after $text_name$ for input and sourcetype, and then one before and after $text_name$ for description&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:45:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294471#M160393</guid>
      <dc:creator>chaninphx</dc:creator>
      <dc:date>2020-09-29T14:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to fit a subsearch in the middle of a search query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294472#M160394</link>
      <description>&lt;P&gt;Try this. (updated per your last comment)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup sourcetypes_raw.csv | lookup sourcetype_lookup.csv sourcetype OUTPUT description
 | where (("$drop_name$"="index" OR "$drop_name$"="sourcetype") AND like('$drop_name$',"$text_name$%") OR ("$drop_name$"="description" AND match(description,"$text_name$")
 | mvcombine sourcetype | sort index | table index sourcetype description
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Essentially, if $drop_name$ is index/sourcetype, it checks full value else, does a match which checks if the values is 'contained' within description field in lookup.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jul 2017 21:23:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294472#M160394</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-07-03T21:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to fit a subsearch in the middle of a search query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294473#M160395</link>
      <description>&lt;P&gt;Ok that worked!  Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 16:32:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294473#M160395</guid>
      <dc:creator>chaninphx</dc:creator>
      <dc:date>2017-07-05T16:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to fit a subsearch in the middle of a search query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294474#M160396</link>
      <description>&lt;P&gt;cool. Don't forget to close the question by Accepting the answer.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 16:44:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fit-a-subsearch-in-the-middle-of-a-search-query/m-p/294474#M160396</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-07-05T16:44:28Z</dc:date>
    </item>
  </channel>
</rss>

