App-ElasticSearch-Utilities
view release on metacpan or search on metacpan
scripts/es-search.pl view on Meta::CPAN
my %params = ();
$params{missing} = 'MISSING' if $OPT{'with-missing'} and $top_agg eq 'terms';
my $field = shift @agg_fields;
$agg_header = "count\tpct\t" . $field;
$agg{$top_agg} = { field => $field, %params };
if( $OPT{'bg-filter'} && $top_agg eq 'significant_terms' ) {
my $bgf = App::ElasticSearch::Utilities::QueryString->new();
my $bgq = $bgf->expand_query_string($OPT{'bg-filter'});
$agg{$top_agg}->{background_filter} = $bgq->query;
}
if( exists $sub_agg{by} ) {
$agg_header = "$OPT{by}\t" . $agg_header;
$agg{$top_agg}->{order} = [ { by => $ORDER }, { "_count" => "desc" } ];
}
$agg{aggregations} = \%sub_agg if keys %sub_agg;
if( exists $OPT{all} ) {
scripts/es-search.pl view on Meta::CPAN
Options:
--help print help
--manual print full manual
--filter Force filter context for all query elements
--show Comma separated list of fields to display, default is ALL, switches to tab output
--tail Continue the query until CTRL+C is sent
--top Perform an aggregation on the fields, by a comma separated list of up to 2 items
--by Perform an aggregation using the result of this, example: --by cardinality:src_ip
--with Perform a sub aggregation on the query
--bg-filter Only used if --top aggregation is significant_terms, applies a background filter
--match-all Enables the ElasticSearch match_all operator
--interval When running aggregations, wrap the aggreation in a date_histogram with this interval
--prefix Takes "field:string" and enables the Lucene prefix query for that field
--exists Field which must be present in the document
--missing Field which must not be present in the document
--size Result size, default is 20, aliased to -n and --limit
--max-batch-size When making requests to ES, retrieve this many docs in a single request, defaults to 50
--all Don't consider result size, just give me *everything*
--asc Sort by ascending timestamp
--desc Sort by descending timestamp (Default)
scripts/es-search.pl view on Meta::CPAN
--with percentiles:out_bytes:50,95,99
--with histogram:out_bytes:1024
=item B<with-missing>
For terms aggregations, adds a C<MISSING> bucket.
=item B<bg-filter>
Only used if the C<--top> aggregation is C<significant_terms>. Sets the
background filter for the C<significant_terms> aggregation.
es-search.pl --top significant_terms:src_ip method:POST file:\/get\/sensitive_data --bg-filter method:POST
=item B<interval>
When performing aggregations, wrap those aggregations in a date_histogram of this interval. This
helps flush out "what changed in the last hour."
=item B<match-all>
( run in 1.091 second using v1.01-cache-2.11-cpan-d8267643d1d )