DQL to filter by non-zero length: Advert.location_query:* (does not work as a filter)
Or in Lucene: Advert.location_query:?*
Results are limited to 10,000 records, unless you use the scroll API which can paginate and also make parallel requests.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Data::Dumper::Concise; | |
use Search::Elasticsearch; | |
my $ekk = Search::Elasticsearch->new( | |
client => '7_0::Direct', | |
nodes => [ 'https://opensearch.example.com/', ], | |
send_get_body_as => 'POST', | |
$ENV{USE_EKK_PROXY} ? (handle_args => { https_proxy => $ENV{USE_EKK_PROXY} }) : (), | |
); | |
my $results = $ekk->search( | |
body => { | |
"size" => 500, | |
"sort" => [ | |
{ | |
"timestamp" => { | |
"order" => "desc", | |
"unmapped_type" => "boolean" | |
} | |
} | |
], | |
"aggs" => { | |
"2" => { | |
"date_histogram" => { | |
"field" => "timestamp", | |
"calendar_interval" => "1d", | |
"time_zone" => "Europe/London", | |
"min_doc_count" => 1 | |
} | |
} | |
}, | |
"stored_fields" => ["*"], | |
"script_fields" => {}, | |
"docvalue_fields" => [ | |
{ | |
"field" => "timestamp", | |
"format" => "date_time" | |
} | |
], | |
"_source" => { | |
"excludes" => [] | |
}, | |
"query" => { | |
"bool" => { | |
"must" => [], | |
"filter" => [ | |
{ | |
"match_all" => {} | |
}, | |
{ | |
"match_phrase" => { | |
"foo_field" => "bar_value" | |
} | |
}, | |
{ | |
"range" => { | |
"timestamp" => { | |
"gte" => "2023-06-28T12:04:15.943Z", | |
"lte" => "2023-09-28T12:04:15.943Z", | |
"format" => "strict_date_optional_time" | |
} | |
} | |
} | |
], | |
"should" => [], | |
"must_not" => [] | |
} | |
}, | |
"highlight" => { | |
"pre_tags" => ["\@opensearch-dashboards-highlighted-field\@"], | |
"post_tags" => ["\@/opensearch-dashboards-highlighted-field\@"], | |
"fields" => { | |
"*" => {} | |
}, | |
"fragment_size" => 2147483647 | |
} | |
} | |
); | |
print Dumper($results); |