Perl, query, sorting

Hi,

can someone help me to add a working sort clause to this search
statement (Perl):

my $result = $es->search(fields => ['message'],
size => $opt->{'size'},
sort => [
"event_time"
]);

How can I say: Sort by event_time in descending order?

Bye,

Oliver

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/52976552.40008%40swe-blog.net.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Oliver

sort => [ { event_time => 'desc'} ]

clint

On 28 November 2013 16:46, Oliver B. Fischer mailsink@swe-blog.net wrote:

Hi,

can someone help me to add a working sort clause to this search statement
(Perl):

my $result = $es->search(fields => ['message'],
size => $opt->{'size'},
sort => [
"event_time"
]);

How can I say: Sort by event_time in descending order?

Bye,

Oliver

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/
msgid/elasticsearch/52976552.40008%40swe-blog.net.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAPt3XKSk5o-N1%3DJROSQV8%3DjSgx34MwOLP7MsRK9kpivqWPd2ig%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

my $result = $es->search(fields => ['message'],
	                     size => $opt->{'size'},
	                     sort => [
	                    	{event_time => 'desc'}
	                     ]);

results in

[Failed to parse source
[{"size":5,"fields":"message","sort":[{"HASH(0x7fc31382d3a0)":{}}]}]]];
nested: SearchParseException[[faststrack-2013.11.25][4]:
from[-1],size[5]: Parse Failure [No mapping found for
[HASH(0x7fc31382d3a0)] in order to sort on]]; }]'},'request' => {'body'
=> undef,'qs' => {'sort' => 'HASH(0x7fc31382d3a0)','fields' =>
'message','size' => 5},'method' => 'GET','serialize' => 'std','path' =>
'/_search','ignore' => },'status_code' => 400}

????

Am 28.11.13 17:12, schrieb Clinton Gormley:

sort => [ { event_time => 'desc'} ]

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/52976F4F.5080500%40swe-blog.net.
For more options, visit https://groups.google.com/groups/opt_out.

Ahhh, sorry - this is a change from the previous Perl API.

The search() method can take a sort parameter at the top level, which goes
into the query string, or inside the body. The query-string version is
somewhat limited, so the body version would look like this:

$es->search(
    fields => ['message'],
    size   => $opt->{size},
    body  => {
        sort => [ { event_time=>'desc'}]
    }
)

clint

On 28 November 2013 17:29, Oliver B. Fischer mailsink@swe-blog.net wrote:

    my $result = $es->search(fields => ['message'],
                                 size => $opt->{'size'},
                                 sort => [
                                    {event_time => 'desc'}
                                 ]);

results in

[Failed to parse source [{"size":5,"fields":"message",
"sort":[{"HASH(0x7fc31382d3a0)":{}}]}]]]; nested: SearchParseException[[faststrack-2013.11.25][4]:
from[-1],size[5]: Parse Failure [No mapping found for
[HASH(0x7fc31382d3a0)] in order to sort on]]; }]'},'request' => {'body' =>
undef,'qs' => {'sort' => 'HASH(0x7fc31382d3a0)','fields' =>
'message','size' => 5},'method' => 'GET','serialize' => 'std','path' =>
'/_search','ignore' => },'status_code' => 400}

????

Am 28.11.13 17:12, schrieb Clinton Gormley:

sort => [ { event_time => 'desc'} ]

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/
msgid/elasticsearch/52976F4F.5080500%40swe-blog.net.

For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAPt3XKRHYPhZ%3DyYHRH1o6SYmZuvaCcpDSeCaK2RMHqNQ8Z1G1g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks, now it works as I need it!

Am 29.11.13 11:11, schrieb Clinton Gormley:

sort => [ { event_time=>'desc'}]

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/5298AE5D.1020908%40swe-blog.net.
For more options, visit https://groups.google.com/groups/opt_out.