Skip to content

Instantly share code, notes, and snippets.

@talexb

talexb/api-test1 Secret

Created August 8, 2013 14:00
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 talexb/95153b422598cd499509 to your computer and use it in GitHub Desktop.
Save talexb/95153b422598cd499509 to your computer and use it in GitHub Desktop.
Testing API -- getting 404 for my local API access.
vagrant@debian:~/dev$ cat api-test1.pl
#!/usr/bin/env perl
use strict;
use warnings;
use ElasticSearch;
{
my $es = ElasticSearch->new( servers => 'localhost:5000', no_refresh => 1 );
# my $es = ElasticSearch->new( servers => 'api.metacpan.org', no_refresh => 1 );
my $scroller = $es->scrolled_search(
query => { match_all => {} },
search_type => 'scan',
scroll => '5m',
index => 'v0',
type => 'author',
size => 15,
);
my $max = 30;
while ( my $result = $scroller->next ) {
print $result->{_source}->{author}, $/;
last unless ( --$max );
}
}
vagrant@debian:~/dev$ perl -w api-test1.pl
[ERROR] ** ElasticSearch::Error::Missing at /usr/local/perlbrew/perls/perl-5.16.2/lib/site_perl/5.16.2/ElasticSearch/Transport/HTTP.pm line 67 :
Not Found (404)
With vars:{
'request' => {
'qs' => {
'scroll' => '5m',
'search_type' => 'scan'
},
'post_process' => undef,
'as_json' => undef,
'cmd' => '/v0/author/_search',
'method' => 'GET',
'data' => {
'query' => {
'match_all' => {}
},
'size' => 15
}
},
'status_code' => 404,
'content' => '{
"code" : 404,
"message" : "v0/author/_search"
}
',
'server' => 'localhost:5000',
'status_msg' => 'Not Found'
}
vagrant@debian:~/dev$
@talexb
Copy link
Author

talexb commented Aug 8, 2013

vagrant@debian:~/dev$ perl -w api-test2.pl

[Thu Aug 8 14:28:00 2013] Protocol: http, Server: localhost:5000

curl -XGET 'http://127.0.0.1:9200/v0/author/MSTROUT?pretty=1'

[Thu Aug 8 14:28:01 2013] Response:

{

"message" : "v0/author/MSTROUT",

"code" : 404

}

[ERROR] ** ElasticSearch::Error::Missing at /usr/local/perlbrew/perls/perl-5.16.2/lib/site_perl/5.16.2/ElasticSearch/Transport/HTTP.pm line 67 :
Not Found (404)

With vars:{
'request' => {
'qs' => {},
'post_process' => undef,
'as_json' => undef,
'cmd' => '/v0/author/MSTROUT',
'method' => 'GET',
'data' => undef
},
'status_code' => 404,
'content' => '{
"code" : 404,
"message" : "v0/author/MSTROUT"
}
',
'server' => 'localhost:5000',
'status_msg' => 'Not Found'
}

vagrant@debian:~/dev$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment