The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Elastic::Model::Types - MooseX::Types for general and internal use

VERSION

version 0.52

SYNOPSIS

    use Elastic::Model::Types qw(GeoPoint);

    has 'point' => (
        is      => 'ro',
        isa     => GeoPoint,
        coerce  => 1
    );

DESCRIPTION

Elastic::Model::Types define a number of MooseX::Types, some for internal use and some which will be useful generally.

PUBLIC TYPES

Keyword

    use Elastic::Model::Types qw(Keyword);

    has 'status' => (
        is  => 'ro',
        isa => Keyword
    );

Keyword is a sub-type of Str. It is provided to make it easy to map string values which should not be analyzed (eg a status field rather than a comment_body field). See "Keyword" in Elastic::Model::TypeMap::ES.

Binary

    use Elastic::Model::Types qw(Binary);

    has 'binary_field' => (
        is  => 'ro',
        isa => Binary
    );

Inherits from the Defined type. Is automatically Base64 encoded/decoded.

GeoPoint

    use Elastic::Model::Types qw(GeoPoint);

    has 'point' => (
        is     => 'ro',
        isa    => GeoPoint,
        coerce => 1,
    );

GeoPoint is a hashref with two keys:

  • lon: a Number between -180 and 180

  • lat: a Number between -90 and 90

It can be coerced from an ArrayRef with [$lon,$lat] and from a Str with "$lat,$lon".

Timestamp

    use Elastic::Model::Types qw(Timestamp);

    has 'timestamp' => (
        is  => 'ro',
        isa => Timestamp
    );

A Timestamp is a Num which holds floating point epoch seconds, with milliseconds resolution. It is automatically mapped as a date field in Elasticsearch.

AUTHOR

Clinton Gormley <drtech@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Clinton Gormley.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.