App-ElasticSearch-Utilities

 view release on metacpan or  search on metacpan

lib/App/ElasticSearch/Utilities/Query.pm  view on Meta::CPAN

package App::ElasticSearch::Utilities::Query;
# ABSTRACT: Object representing ES Queries

use strict;
use warnings;

our $VERSION = '8.8'; # VERSION

use App::ElasticSearch::Utilities qw(es_request es_indices);
use App::ElasticSearch::Utilities::Aggregations;
use CLI::Helpers qw(:output);
use Clone qw(clone);
use Const::Fast;
use Moo;
use Ref::Util qw(is_arrayref is_hashref);
use Types::Standard qw(ArrayRef Enum HashRef Int Maybe Str);
use Types::ElasticSearch qw(TimeConstant is_TimeConstant);
use namespace::autoclean;

const my $AGG_KEY => 'aggregations';
my %TO = (
    array_ref => sub { defined $_[0] && is_arrayref($_[0]) ? $_[0] : defined $_[0] ? [ $_[0] ] : $_[0] },
);


has fields_meta => (
    is => 'rw',
    isa => HashRef,
    default => sub { {} },
);


has query_stash => (
    is       => 'rw',
    isa      => HashRef,
    lazy     => 1,
    init_arg => undef,
    default  => sub {{}},
);


has scroll_id => (
    is       => 'rw',
    isa      => Str,
    init_arg => undef,
    writer   => 'set_scroll_id',
    clearer  => 1,
);



has 'minimum_should_match' => (
    is  => 'rw',
    isa => Str,
);

my %QUERY = (
    must        => { isa => ArrayRef, coerce => $TO{array_ref} },
    must_not    => { isa => ArrayRef, coerce => $TO{array_ref} },
    should      => { isa => ArrayRef, coerce => $TO{array_ref} },
    filter      => { isa => ArrayRef, coerce => $TO{array_ref} },
    nested      => { isa => HashRef },
    nested_path => { isa => Str },
);



my %REQUEST_BODY = (
    from         => { isa => Int },
    size         => { default => sub {50},    isa => Int },
    fields       => { isa => ArrayRef, coerce => $TO{array_ref} },
    sort         => { isa => ArrayRef, coerce => $TO{array_ref} },
    aggregations => { isa => HashRef },
);

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.936 second using v1.00-cache-2.02-grep-82fe00e-cpan-48ebf85a1963 )