<?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 When do I need to surround a field name with single ticks, double ticks, and when do I not need them at all in a search? in Splunk Enterprise Security</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/When-do-I-need-to-surround-a-field-name-with-single-ticks-double/m-p/144364#M522</link>
    <description>&lt;P&gt;I'm trying to integrate McAfee data into ES and I am having difficulties using the datamodel command.&lt;/P&gt;

&lt;P&gt;Why does this search work (it returns results):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   | datamodel "Malware" "Malware_Attacks" search | where 'Malware_Attacks.category'="av.detect"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And this one does not (does not return results, but i do not get syntax errors):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| datamodel "Malware" "Malware_Attacks" search | search 'Malware_Attacks.category'="av.detect"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Chris&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Update &lt;/P&gt;

&lt;P&gt;This works:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| datamodel "Malware" "Malware_Attacks" search | search "Malware_Attacks.category"="av.detect"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And so does this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| datamodel "Malware" "Malware_Attacks" search | search Malware_Attacks.category="av.detect"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I guess the question should be: When do I need to surround a field name with single ticks, when are double ticks ok and when do I not need them at all?&lt;/P&gt;</description>
    <pubDate>Fri, 13 Feb 2015 21:54:37 GMT</pubDate>
    <dc:creator>chris</dc:creator>
    <dc:date>2015-02-13T21:54:37Z</dc:date>
    <item>
      <title>When do I need to surround a field name with single ticks, double ticks, and when do I not need them at all in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/When-do-I-need-to-surround-a-field-name-with-single-ticks-double/m-p/144364#M522</link>
      <description>&lt;P&gt;I'm trying to integrate McAfee data into ES and I am having difficulties using the datamodel command.&lt;/P&gt;

&lt;P&gt;Why does this search work (it returns results):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   | datamodel "Malware" "Malware_Attacks" search | where 'Malware_Attacks.category'="av.detect"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And this one does not (does not return results, but i do not get syntax errors):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| datamodel "Malware" "Malware_Attacks" search | search 'Malware_Attacks.category'="av.detect"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Chris&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Update &lt;/P&gt;

&lt;P&gt;This works:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| datamodel "Malware" "Malware_Attacks" search | search "Malware_Attacks.category"="av.detect"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And so does this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| datamodel "Malware" "Malware_Attacks" search | search Malware_Attacks.category="av.detect"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I guess the question should be: When do I need to surround a field name with single ticks, when are double ticks ok and when do I not need them at all?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Feb 2015 21:54:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/When-do-I-need-to-surround-a-field-name-with-single-ticks-double/m-p/144364#M522</guid>
      <dc:creator>chris</dc:creator>
      <dc:date>2015-02-13T21:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: When do I need to surround a field name with single ticks, double ticks, and when do I not need them at all in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/When-do-I-need-to-surround-a-field-name-with-single-ticks-double/m-p/144365#M523</link>
      <description>&lt;P&gt;Hi chris,&lt;/P&gt;

&lt;P&gt;I cannot answer why it is this way; but from my experience and tests I can try to answer on how to use it.&lt;BR /&gt;
Let's start with the difference of &lt;CODE&gt;where&lt;/CODE&gt; and &lt;CODE&gt;search&lt;/CODE&gt;:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Use &lt;CODE&gt;where&lt;/CODE&gt; if you want to compare two fields value&lt;/LI&gt;
&lt;LI&gt;Use &lt;CODE&gt;search&lt;/CODE&gt; if you want to search for a field containing a string or value&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Next, there is a little hint in the docs &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Where" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Where&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;If the expression references a field name that contains non-alphanumeric characters, it needs to be surrounded by single quotes; for example, new=count+'server-1'.

If the expression references literal strings that contains non-alphanumeric characters, it needs to be surrounded by double quotes; for example, new="server-"+count.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, let's test this with this run everywhere commands, all done on the same server over &lt;CODE&gt;Previous week&lt;/CODE&gt; timerange:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| datamodel "internal_server" "systemwide_search_load_" search | eval foo="15" | where 'server.active_hist_searches'&amp;gt;='foo'
| datamodel "internal_server" "systemwide_search_load_" search | eval foo="15" | where 'server.active_hist_searches'&amp;gt;=foo
| datamodel "internal_server" "systemwide_search_load_" search | search server.active_hist_searches&amp;gt;=15
| datamodel "internal_server" "systemwide_search_load_" search | search "server.active_hist_searches"&amp;gt;=15
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;All the above searches will work, because they use the correct search syntax and the result is &lt;CODE&gt;108&lt;/CODE&gt; events.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| datamodel "internal_server" "systemwide_search_load_" search | search "server.active_hist_searches"&amp;gt;="15"
| datamodel "internal_server" "systemwide_search_load_" search | search server.active_hist_searches&amp;gt;="15"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above searches will return wrong events, because they search for literal string values of 15, the result is &lt;CODE&gt;566&lt;/CODE&gt; events.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| datamodel "internal_server" "systemwide_search_load_" search | eval foo="15" | where "server.active_hist_searches"&amp;gt;='foo'
| datamodel "internal_server" "systemwide_search_load_" search | eval foo="15" | where "server.active_hist_searches"&amp;gt;="foo"
| datamodel "internal_server" "systemwide_search_load_" search | eval foo="15" | where "server.active_hist_searches"&amp;gt;=foo
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above searches will not work, because it will references literal strings that contains non-alphanumeric characters as field, the result in this case is &lt;CODE&gt;811&lt;/CODE&gt; or all events.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| datamodel "internal_server" "systemwide_search_load_" search | eval foo="15" | where server.active_hist_searches&amp;gt;=foo
| datamodel "internal_server" "systemwide_search_load_" search | eval foo="15" | where 'server.active_hist_searches'&amp;gt;="foo"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will not work at all, returning &lt;CODE&gt;0&lt;/CODE&gt; events.&lt;/P&gt;

&lt;P&gt;So, after all this testing I can say the following:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;use &lt;CODE&gt;'&lt;/CODE&gt; single quotes when using the &lt;CODE&gt;where&lt;/CODE&gt; command&lt;/LI&gt;
&lt;LI&gt;use &lt;CODE&gt;"&lt;/CODE&gt; double quotes or no quotes when using the &lt;CODE&gt;search&lt;/CODE&gt; command&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Hope this helps ....&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;PS: if you need the **why&lt;/EM&gt;* it is this way, open a support case or ask the same on the IRC channel #splunk @ efnet.org*&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:54:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/When-do-I-need-to-surround-a-field-name-with-single-ticks-double/m-p/144365#M523</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2020-09-28T18:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: When do I need to surround a field name with single ticks, double ticks, and when do I not need them at all in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/When-do-I-need-to-surround-a-field-name-with-single-ticks-double/m-p/144366#M524</link>
      <description>&lt;P&gt;Thanks for testing the different variations.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Feb 2015 10:22:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/When-do-I-need-to-surround-a-field-name-with-single-ticks-double/m-p/144366#M524</guid>
      <dc:creator>chris</dc:creator>
      <dc:date>2015-02-16T10:22:13Z</dc:date>
    </item>
  </channel>
</rss>

