I have a remote node that I am attempting to connect to that requires an
api key as a URL parameter in addition to the body in order to get it to
work.
The code is as follows:
#!/usr/bin/perl
use v5.14;
use warnings;
use Search::Elasticsearch;
use Data::Dumper;
my $API_KEY='API_KEY';
my $ES = Search::Elasticsearch->new(
cxn_pool => 'Static::NoPing',
nodes => [{
scheme => 'https',
host => 'service.host.com',
port => 443,
path => '/api/es/a_path',
}],
#send_get_body_as => 'POST',
trace_to => 'Stdout',
log_to => 'Stdout',
);
my $res = $ES->search(
params => {
api_key => $API_KEY,
},
body => {
query => {
bool => {
must => {
query_string => {
default_field => "_all",
query => "thisisasitethatdoesntexist.com",
default_operator => "AND"
}
}
}
}
}
);
print Dumper($res);
The generated curl is:
Request to: https://service.host.com:443/api/es/a_path
curl -XGET 'http://localhost:9200/_search?api_key=API_KEY&pretty=1' -d '
{
"query" : {
"bool" : {
"must" : {
"query_string" : {
"query" : "thisisasitethatdoesntexist.com",
"default_field" : "_all",
"default_operator" : "AND"
}
}
}
}
}
'
When I replace localhost and the path with the proper host and path and run
the curl command directly from the command line, I get zero hits back,
which is what I expect. If I run the above perl, however, I get many
millions of results back, which is exactly the same as what I get when I
remove the body from the curl query (-d ''). So it seems that the
combination of params and body causes body to get eaten? I looked at the
code, but I couldn't find where this might be happening. Any help?
--
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/b990961c-a129-4cd0-b1e0-46f33f86c4ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.