<?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: Multivalue fields with numeric values don't play nice with &amp;gt; and &amp;lt; in the search command. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-with-numeric-values-don-t-play-nice-with-gt/m-p/257871#M77216</link>
    <description>&lt;P&gt;Just for your specific criteria (mvnumeric&amp;gt;0), try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count as numeric | eval numeric=mvrange(3,8) | mvexpand numeric | eval categorical=case(numeric%3=0,"A",numeric%3=1,"B",numeric%3=2,"C") | stats values(numeric) as mvnumeric by categorical 
| eventstats min(mvnumeric) as min by categorical | where min&amp;gt;0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count as numeric | eval numeric=mvrange(3,8) | mvexpand numeric | eval categorical=case(numeric%3=0,"A",numeric%3=1,"B",numeric%3=2,"C") | stats values(numeric) as mvnumeric by categorical 
| where isnotnull(mvfilter(mvnumeric&amp;gt;0))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 24 Mar 2016 05:47:02 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-03-24T05:47:02Z</dc:date>
    <item>
      <title>Multivalue fields with numeric values don't play nice with &gt; and &lt; in the search command.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-with-numeric-values-don-t-play-nice-with-gt/m-p/257870#M77215</link>
      <description>&lt;P&gt;We frequently have search results where for one or more numeric fields, each row might have only one value for the numeric field or the row might have a multivalued value for that numeric field. &lt;/P&gt;

&lt;P&gt;Here is a made up search duplicating the basic situation.  Paste this into your search bar. &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| stats count as numeric | eval numeric=mvrange(3,8) | mvexpand numeric | eval categorical=case(numeric%3=0,"A",numeric%3=1,"B",numeric%3=2,"C") | stats values(numeric) as mvnumeric by categorical&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This dummy search will give you results of &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|    categorical   |    mvnumeric    |
|    A             |     3           |
|                  |     6           |                         
-------------------------------------- 
|    B             |     4           |
|                  |     7           |                         
--------------------------------------
|    C             |     5           |
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note in particular that the first two rows have multivalued values and the last row has only a regular single value. &lt;/P&gt;

&lt;P&gt;Now say we add a search of &lt;CODE&gt;| search mvnumeric&amp;gt;0&lt;/CODE&gt; to the end to filter this set. &lt;/P&gt;

&lt;P&gt;Since all the rows have a numeric value greater than zero,  in fact since &lt;EM&gt;all&lt;/EM&gt; values are greater than zero, I'd expect all rows to get returned. &lt;/P&gt;

&lt;P&gt;However only the value with the single-value gets returned. Likewise with other terms you can see that the greater-than and less-than operators just don't work with any multivalue  rows - the rows always fail to match. &lt;BR /&gt;
Is this a known bug?  Is there any magic to be worked in the search language?&lt;/P&gt;

&lt;P&gt;mvexpand offers a sort of a workaround,  but   &lt;CODE&gt;| mvexpand | search mvnumeric&amp;gt;4&lt;/CODE&gt;  doesn't  work cause that'll throw away the other values and we need the whole picture on the final rows. &lt;/P&gt;

&lt;P&gt;Which leaves this sort of thing and it's way too clunky to be of use here.. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| mvexpand mvnumeric | eval matchesOurExpression=if(mvnumeric&amp;gt;N,1,0) | stats values(*) as * by &amp;lt;the id fields by which we were grouping before we mvexpanded&amp;gt; | search matchesOurExpression=1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Mar 2016 03:14:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-with-numeric-values-don-t-play-nice-with-gt/m-p/257870#M77215</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2016-03-24T03:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: Multivalue fields with numeric values don't play nice with &gt; and &lt; in the search command.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-with-numeric-values-don-t-play-nice-with-gt/m-p/257871#M77216</link>
      <description>&lt;P&gt;Just for your specific criteria (mvnumeric&amp;gt;0), try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count as numeric | eval numeric=mvrange(3,8) | mvexpand numeric | eval categorical=case(numeric%3=0,"A",numeric%3=1,"B",numeric%3=2,"C") | stats values(numeric) as mvnumeric by categorical 
| eventstats min(mvnumeric) as min by categorical | where min&amp;gt;0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count as numeric | eval numeric=mvrange(3,8) | mvexpand numeric | eval categorical=case(numeric%3=0,"A",numeric%3=1,"B",numeric%3=2,"C") | stats values(numeric) as mvnumeric by categorical 
| where isnotnull(mvfilter(mvnumeric&amp;gt;0))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Mar 2016 05:47:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-with-numeric-values-don-t-play-nice-with-gt/m-p/257871#M77216</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-03-24T05:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Multivalue fields with numeric values don't play nice with &gt; and &lt; in the search command.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-with-numeric-values-don-t-play-nice-with-gt/m-p/257872#M77217</link>
      <description>&lt;P&gt;Just to clarify, if you have a row with multivalued field "mvnumeric" and the values of that multivalued field are 3 and 6 (just like in the first row of your example), and you do a search for "mvnumeric&amp;gt;3", do you want the entire row to stay because it contains a 6, or do you want to discard it because not all of your values in that row are &amp;gt;3?&lt;BR /&gt;
This question is the reason you can't do a search like "search mvnumeric&amp;gt;3", because it can be answered either way, depending on what you want. It is not precise enough.&lt;/P&gt;

&lt;P&gt;The good news is, you've probably heard of &lt;CODE&gt;mvfilter&lt;/CODE&gt; (just realized who asked the question :)) It might help you, see here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval keep=mvfilter(mvnumeric&amp;gt;6) | where mvcount(keep)&amp;gt;=1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will remove all results in which the highest available number is less than 6. Set that to 0, and you will filter out all rows which only have negative values. Or do it like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval keep=mvfilter(mvnumeric&amp;gt;3) | where mvcount(mvnumeric)=mvcount(keep)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will remove any row which contains numbers &lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt; (in your data, the second row).&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2016 12:29:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-with-numeric-values-don-t-play-nice-with-gt/m-p/257872#M77217</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2016-03-24T12:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: Multivalue fields with numeric values don't play nice with &gt; and &lt; in the search command.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-with-numeric-values-don-t-play-nice-with-gt/m-p/257873#M77218</link>
      <description>&lt;P&gt;Yes - I realize there's remaining ambiguity on how exactly it should work.  I started trying to get into that too in the question.   Ultimately I think it's a false problem though.      It seems like any choice retains this ambiguity, but one of the two choices actually leads to a fully consistent and flexible system.  I think. &lt;/P&gt;

&lt;P&gt;To explain -- I think it should have the behavior where   mvnumeric&amp;gt;N    matches even if only one of the values is greater than N.    Then for when the user needs the opposite behavior (matching only when all of the values are greater than  N),  they can do &lt;CODE&gt;NOT mvnumeric&amp;lt;=N&lt;/CODE&gt;   and everyone gets their cake and gets to eat it too.   &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;BR /&gt;
I wouldn't put it past the Search and Indexing team at Splunk to have thought through all this years ago and I was quite surprised to find &lt;EM&gt;neither&lt;/EM&gt; way implemented on multivalue numeric fields!!&lt;/P&gt;

&lt;P&gt;Whereas if they had it default the other way I don't think the language would retain the same flexibility.    also.....  mvnumeric&amp;gt;N matching even if only one of the values is greater than N happens to be what I need here. &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt; &lt;/P&gt;

&lt;P&gt;Thanks for the mvfilter solution.   It's definitely less evil than mvexpanding/painting-with-eval/stats values(*) by id1 id2 id3/filtering.      still not really much practical help to me in my customer case here but thanks very much.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2016 16:48:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-with-numeric-values-don-t-play-nice-with-gt/m-p/257873#M77218</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2016-03-24T16:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Multivalue fields with numeric values don't play nice with &gt; and &lt; in the search command.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-with-numeric-values-don-t-play-nice-with-gt/m-p/257874#M77219</link>
      <description>&lt;P&gt;Actually this will almost work.   We're &lt;EM&gt;already&lt;/EM&gt; in a stats &amp;lt;&amp;gt; by id1 id2 id3  situation here,  so with that extra assumption in hand, I can just do &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| eventstats min(mvnumeric) as tempMin by id1 id2 id3 | where tempMin&amp;gt;0&lt;/CODE&gt;  and be done. &lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2016 16:55:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-with-numeric-values-don-t-play-nice-with-gt/m-p/257874#M77219</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2016-03-24T16:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Multivalue fields with numeric values don't play nice with &gt; and &lt; in the search command.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-with-numeric-values-don-t-play-nice-with-gt/m-p/257875#M77220</link>
      <description>&lt;P&gt;I agree with "should match if at least one mv member matches" - that would line up with the behaviour for &lt;CODE&gt;| search mvfield="foo"&lt;/CODE&gt;, it'll match if one member matches &lt;CODE&gt;"foo"&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;For the generic case with as-is SPL I don't see a better way than &lt;CODE&gt;| where mvcount(mvfilter(mvnumeric &amp;gt; 0)) &amp;gt; 0&lt;/CODE&gt;. Any kind of &lt;CODE&gt;eventstats&lt;/CODE&gt;-powered thing is going to be expensive over large result sets, and anything involving &lt;CODE&gt;mvexpand&lt;/CODE&gt; is going to be even more expensive.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2016 15:46:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multivalue-fields-with-numeric-values-don-t-play-nice-with-gt/m-p/257875#M77220</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-03-25T15:46:13Z</dc:date>
    </item>
  </channel>
</rss>

