Hello Gurus and Newcomers of THE LANGUAGE! Seeking your wisdom and help with Search::Elasticsearch module... I was actually very surprised to see no questions about this given limited Perl docs on the matter.

I am trying to match the log dates AND filter or search by time as well. The following works as expected giving me first 3 lines from the log for a given date:

my $es = Search::Elasticsearch->new( nodes => 'logs.server.local:9200', cxn_pool => 'Sniff', ## "web servers and Elasticsearch server +s are on the same network" ); my $results = $es->search( body => { query => { filtered => { query => { term => { component=> 'ens_iis' } }, filter => { and => [ { term => { date=> '2014-04-22' } }, ], }, } } }, from => 0, size => 3, timeout => 60, );

However for the life of me i cannot get the time filter to work! I tried various different ways and either get incorrect results or none at all. Here's the most logical (in my eyes) attempt of such search that does NOT work:

my $results = $es->search( body => { query => { filtered => { query => { term => { component=> 'ens_iis' } }, filter => { and => [ { term => { date=> '2014-04-22' } }, { range => { time => { gte => '02:00:00', lt => '07:55:00' } } }, ], }, } } }, from => 0, size => 3, timeout => 60, );

This returns the same rows as without the filter with timestamps starting 00:03:56. I tried various ways to escape the timestamps but without expected results.

Im not sure what i am missing here and will be grateful for any guidance and advice!

Thank you!


In reply to Search::Elasticsearch need to filter by time by Mushka

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.