Skip to content

Instantly share code, notes, and snippets.

@szabgab
Created October 22, 2014 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szabgab/7a08dd2d108177618ac0 to your computer and use it in GitHub Desktop.
Save szabgab/7a08dd2d108177618ac0 to your computer and use it in GitHub Desktop.
MetaCPAN API error
use strict;
use warnings;
use Data::Dumper qw(Dumper);
use HTTP::Tiny;
use JSON qw(to_json);
my $ua = HTTP::Tiny->new();
my $query_json = to_json {
query => {
match_all => {},
},
filter => {
and => [
{ term => { status => 'latest', } },
{
"range" => {
"date" => {
"from" => "2010-06-05T00:00:00",
"to" => "2011-06-05T00:00:00",
},
},
},
]
},
#fields => ["name", "author", "status", "date", "abstract"],
sort => "date:desc",
size => 2,
};
print Dumper $ua->request(
'POST',
'http://api.metacpan.org/v0/release/_search',
{
headers => { 'Content-Type' => 'application/json' },
content => $query_json,
}
);
$VAR1 = {
'success' => '',
'status' => '500',
'headers' => {
'content-length' => '987',
'server' => 'nginx/1.6.2',
'content-type' => 'text/plain; charset=UTF-8',
'date' => 'Wed, 22 Oct 2014 15:03:49 GMT',
'connection' => 'keep-alive',
'surrogate-control' => 'no-store'
},
'url' => 'http://api.metacpan.org/v0/release/_search',
'reason' => 'Internal Server Error',
'protocol' => 'HTTP/1.1',
'content' => 'SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[MviAwe4BT1-a4OcbrYWb0g][cpan_v1][0]: SearchParseException[[cpan_v1][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"sort":"date:desc","filter":{"and":[{"term":{"status":"latest"}},{"range":{"date":{"from":"2010-06-05T00:00:00","to":"2011-06-05T00:00:00"}}}]},"size":2,"query":{"match_all":{}}}]]]; nested: SearchParseException[[cpan_v1][0]: from[-1],size[-1]: Parse Failure [No mapping found for [filter] in order to sort on]]; }{[MviAwe4BT1-a4OcbrYWb0g][cpan_v1][4]: SearchParseException[[cpan_v1][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"sort":"date:desc","filter":{"and":[{"term":{"status":"latest"}},{"range":{"date":{"from":"2010-06-05T00:00:00","to":"2011-06-05T00:00:00"}}}]},"size":2,"query":{"match_all":{}}}]]]; nested: SearchParseException[[cpan_v1][4]: from[-1],size[-1]: Parse Failure [No mapping found for [filter] in order to sort on]]; }]'
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment