diff --git a/scripts/es-search.pl b/scripts/es-search.pl index 62b2fe4..fad56f7 100755 --- a/scripts/es-search.pl +++ b/scripts/es-search.pl @@ -50,6 +50,7 @@ top=s interval=s with=s@ + with-missing or )); @@ -246,10 +247,13 @@ # Skip invalid elements next unless defined $field and defined $size and $size > 0; + my %params = (); my $id = "$type-$field"; # If a term agg and we haven't used this field name, simplify it if( $type =~ /terms$/ && !$sub_agg{$field} ) { $id = $field; + $params{size} = $size; + $params{missing} = 'MISSING' if $OPT{'with-missing'}; } if( $type =~ /histogram|stats|percentiles/ && !$OPT{'no-implications'} ) { @@ -260,17 +264,20 @@ $sub_agg{$id} = { $type => { field => $field, - $type =~ /terms/ ? (size => $size) : (), $type eq 'percentiles' ? ( percents => [split /,/, $pcts] ) : (), $type eq 'histogram' ? ( interval => $hi ) : (), + %params, } }; } } + 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 }; + $agg{$top_agg} = { field => $field, %params }; if( $OPT{'bg-filter'} && $top_agg eq 'significant_terms' ) { my $bgf = App::ElasticSearch::Utilities::QueryString->new(); @@ -921,6 +928,10 @@ =head1 OPTIONS --with percentiles:out_bytes:50,95,99 --with histogram:out_bytes:1024 +=item B + +For terms aggregations, adds a C bucket. + =item B Only used if the C<--top> aggregation is C. Sets the