<?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 edit my search to use a macro to return an integer being fed a single argument being supplied as an eval variable? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-use-a-macro-to-return-an-integer-being/m-p/254241#M76132</link>
    <description>&lt;P&gt;That does work ... It seems that the macro name delimiter/enclosing character must be the " ` "  character (ASCII 96) and not the standard single quote " ' " (ASCII 39).  My particular issue is the browser I am using to get to Splunk Enterprise is Firefox and for some weird reason it does not show the ASCII 96 character on the screen.  Always an adventure ...  Thanks ...&lt;/P&gt;</description>
    <pubDate>Fri, 02 Dec 2016 18:33:17 GMT</pubDate>
    <dc:creator>bensinger</dc:creator>
    <dc:date>2016-12-02T18:33:17Z</dc:date>
    <item>
      <title>How to edit my search to use a macro to return an integer being fed a single argument being supplied as an eval variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-use-a-macro-to-return-an-integer-being/m-p/254239#M76130</link>
      <description>&lt;P&gt;Tried doing this via the Splunk docs and the macro is not being processed.  &lt;/P&gt;

&lt;P&gt;My example ...&lt;BR /&gt;
My macro is named &lt;STRONG&gt;wordweight02&lt;/STRONG&gt; and takes a single argument which I identify as named "words" in the macro definition.  I expect it to return an integer value.  Source for macro follows ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if(like($words$, "% dog %"), 10 ,0) + if(like($words$, "% cat %"), 10 ,0) +     if(like($words$, "% snake %"), 15 ,0) + 
if(like($words$, "% chicken %"), 20 ,0) + if(like($words$, "% truck %"), 25 ,0) + if(like($words$, "% car %"), 25 ,0) + 
if(like($words$, "% rocket %"), 25 ,0) + if(like($words$, "% and %"), 1 ,0) + if(like($words$, "% he %"), 5 ,0) + 
if(like($words$, "% she %"), 5 ,0) +    if(like($words$, "% they %"), 5 ,0) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2203iD2DE52C15438D1AA/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;So now I want to use my macro to return a word weight for selected words occurring in a sentence.  The sentences are being captured in an index in a field called "sentence".  In my example, I can have duplicate values in "sentence" so ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex | 
 eval lcsentence=lower(sentence) | 
 eval wordweight=('wordweight02(words=$lcsentence$)') |
  search wordweight&amp;gt;0 | 
  stats count(sentence) as countsentence, by wordweight, sentence | 
  eval sentencewordscore=wordweight*countsentence |
  sort -sentencewordscore 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The macro never seems to return a value ... Any ideas?  Splunk docs are a little light on this stuff.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 17:01:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-use-a-macro-to-return-an-integer-being/m-p/254239#M76130</guid>
      <dc:creator>bensinger</dc:creator>
      <dc:date>2016-12-02T17:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to use a macro to return an integer being fed a single argument being supplied as an eval variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-use-a-macro-to-return-an-integer-being/m-p/254240#M76131</link>
      <description>&lt;P&gt;Try just using the field name when you pass it to the macro. Like this &lt;CODE&gt;| eval wordweight='wordweight02(lcsentence)'&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 18:14:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-use-a-macro-to-return-an-integer-being/m-p/254240#M76131</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-12-02T18:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to use a macro to return an integer being fed a single argument being supplied as an eval variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-use-a-macro-to-return-an-integer-being/m-p/254241#M76132</link>
      <description>&lt;P&gt;That does work ... It seems that the macro name delimiter/enclosing character must be the " ` "  character (ASCII 96) and not the standard single quote " ' " (ASCII 39).  My particular issue is the browser I am using to get to Splunk Enterprise is Firefox and for some weird reason it does not show the ASCII 96 character on the screen.  Always an adventure ...  Thanks ...&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 18:33:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-use-a-macro-to-return-an-integer-being/m-p/254241#M76132</guid>
      <dc:creator>bensinger</dc:creator>
      <dc:date>2016-12-02T18:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to use a macro to return an integer being fed a single argument being supplied as an eval variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-use-a-macro-to-return-an-integer-being/m-p/254242#M76133</link>
      <description>&lt;P&gt;You might want to look into the Machine Learning Tool Kit and TF IDF. I am not familiar with this tool yet... but it sounds like where you are headed based on docs and machine learning course I am taking. &lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/MLApp/2.0.0/User/Algorithms"&gt;https://docs.splunk.com/Documentation/MLApp/2.0.0/User/Algorithms&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 19:33:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-use-a-macro-to-return-an-integer-being/m-p/254242#M76133</guid>
      <dc:creator>snoobzilla</dc:creator>
      <dc:date>2016-12-02T19:33:32Z</dc:date>
    </item>
  </channel>
</rss>

