我使用Search::Elasticsearch来查询MetaCPAN。
my $es = Search::Elasticsearch->new(
cxn_pool => 'Static::NoPing',
nodes => 'api.metacpan.org:80',
);
my $scroller = $es->scroll_helper(
index => 'v0',
type => 'release',
search_type => 'scan',
scroll => '2m',
size => $size,
body => {
fields => [qw(author archive date)],
query => { range => { date => { gte => $date } } },
},
);
这可行,但我想将HTTP User-Agent标头设置为自定义值,以便在出现问题时可以识别我的请求。我如何使用Search :: Elasticsearch?
执行此操作答案 0 :(得分:4)
您可以使用handle_args
将参数传递给handle
构造函数。因此,对于默认HTTP::Tiny
,您可以使用agent
:
my $es = Search::Elasticsearch->new(
cxn_pool => 'Static::NoPing',
nodes => 'api.metacpan.org:80',
handle_args => { agent => "youragent/0.1" },
);