<?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 to search based on optional text fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-search-based-on-optional-text-fields/m-p/499823#M195047</link>
    <description>&lt;P&gt;I have couple of text boxes (Tracking no and Track Type) in my bashboard and both are optional. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;fieldset submitButton="true" autoRun="false"&amp;gt;
    &amp;lt;input type="text" token="TrackingNo"&amp;gt;
      &amp;lt;label&amp;gt;Tracking Number&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;&amp;lt;/default&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;condition value=""&amp;gt;
          &amp;lt;set token="TrackingNo"&amp;gt;*&amp;lt;/set&amp;gt;
        &amp;lt;/condition&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
    &amp;lt;input type="text" token="Tracktype"&amp;gt;
      &amp;lt;label&amp;gt;Tracktype&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;&amp;lt;/default&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;condition value=""&amp;gt;
          &amp;lt;set token="Tracktype"&amp;gt;*&amp;lt;/set&amp;gt;
        &amp;lt;/condition&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Scenario 1:&lt;/STRONG&gt; Once the user clicks submit button with out any input, dashboard should display all the data.&lt;BR /&gt;
&lt;STRONG&gt;Scenario 2:&lt;/STRONG&gt; By giving both values, it should fetch all the records exactly matching with Tracking no and Track Type&lt;BR /&gt;
&lt;STRONG&gt;Scenario 3:&lt;/STRONG&gt; By giving only Track no, it should fetch all the records matching with Tracking no, irrespective of Track type (With above simple XML code, track type is supplied as &lt;EM&gt;. )&lt;BR /&gt;
*&lt;/EM&gt;&lt;STRONG&gt;Scenario 4:&lt;/STRONG&gt;** By giving only Track type, it should fetch all the records matching with Tracking type, irrespective of Track no. (With above simple XML code, Tracking no is supplied as *. )&lt;/P&gt;

&lt;P&gt;Please help me to construct the search query&lt;/P&gt;</description>
    <pubDate>Fri, 15 May 2020 18:53:59 GMT</pubDate>
    <dc:creator>rarangarajanspl</dc:creator>
    <dc:date>2020-05-15T18:53:59Z</dc:date>
    <item>
      <title>how to search based on optional text fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-search-based-on-optional-text-fields/m-p/499823#M195047</link>
      <description>&lt;P&gt;I have couple of text boxes (Tracking no and Track Type) in my bashboard and both are optional. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;fieldset submitButton="true" autoRun="false"&amp;gt;
    &amp;lt;input type="text" token="TrackingNo"&amp;gt;
      &amp;lt;label&amp;gt;Tracking Number&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;&amp;lt;/default&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;condition value=""&amp;gt;
          &amp;lt;set token="TrackingNo"&amp;gt;*&amp;lt;/set&amp;gt;
        &amp;lt;/condition&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
    &amp;lt;input type="text" token="Tracktype"&amp;gt;
      &amp;lt;label&amp;gt;Tracktype&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;&amp;lt;/default&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;condition value=""&amp;gt;
          &amp;lt;set token="Tracktype"&amp;gt;*&amp;lt;/set&amp;gt;
        &amp;lt;/condition&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Scenario 1:&lt;/STRONG&gt; Once the user clicks submit button with out any input, dashboard should display all the data.&lt;BR /&gt;
&lt;STRONG&gt;Scenario 2:&lt;/STRONG&gt; By giving both values, it should fetch all the records exactly matching with Tracking no and Track Type&lt;BR /&gt;
&lt;STRONG&gt;Scenario 3:&lt;/STRONG&gt; By giving only Track no, it should fetch all the records matching with Tracking no, irrespective of Track type (With above simple XML code, track type is supplied as &lt;EM&gt;. )&lt;BR /&gt;
*&lt;/EM&gt;&lt;STRONG&gt;Scenario 4:&lt;/STRONG&gt;** By giving only Track type, it should fetch all the records matching with Tracking type, irrespective of Track no. (With above simple XML code, Tracking no is supplied as *. )&lt;/P&gt;

&lt;P&gt;Please help me to construct the search query&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2020 18:53:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-search-based-on-optional-text-fields/m-p/499823#M195047</guid>
      <dc:creator>rarangarajanspl</dc:creator>
      <dc:date>2020-05-15T18:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to search based on optional text fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-search-based-on-optional-text-fields/m-p/499824#M195048</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/44436"&gt;@rarangarajanspl&lt;/a&gt;unk,&lt;BR /&gt;
if Track_No and Track_Type are present in all events, you can use " &lt;CODE&gt;*&lt;/CODE&gt; " as default value.&lt;/P&gt;

&lt;P&gt;There's a problem if one of the above fields is missed in some events, because the default condition &lt;CODE&gt;field=*&lt;/CODE&gt; excludes events without this field (you have this problem in 1, 3 and 4 case).&lt;/P&gt;

&lt;P&gt;So, in this second case, (if acceptable for you) you could use a more complicated default values (e.g. &lt;CODE&gt;Track_Type=* OR NOT Track_Type=*&lt;/CODE&gt; ).&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:27:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-search-based-on-optional-text-fields/m-p/499824#M195048</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-09-30T05:27:28Z</dc:date>
    </item>
  </channel>
</rss>

