Elastic::Doc - Adds Elastic::Model functionality to your object classes
version 0.02
package MyApp::User; use Elastic::Doc; has 'name' => ( is => 'rw', isa => 'Str' ); no Elastic::Doc;
package MyApp::User; use Elastic::Doc; has_mapping { _ttl => { # delete documents/object after 2 hours enabled => 1, default => '2h' } }; has 'user' => ( is => 'ro', isa => 'MyApp::User' ); has 'title' => ( is => 'rw', isa => 'Str', analyzer => 'edge_ngrams' # use custom analyzer ); has 'body' => ( is => 'rw', isa => 'Str', analyzer => 'english', # use builtin analyzer ); has 'created' => ( is => 'ro', isa => 'DateTime', default => sub { DateTime->new } ); has 'tag' => ( is => 'ro', isa => 'Str', index => 'not_analyzed' # index exact value ); no Elastic::Doc;
Elastic::Doc prepares your object classes (eg MyApp::User) for storage in ElasticSearch, by:
MyApp::User
applying Elastic::Model::Role::Doc to your class and Elastic::Model::Meta::Doc to its metaclass
adding keywords to your attribute declarations, to give you control over how they are indexed (see Elastic::Manual::Attributes)
wrapping your accessors to allow auto-inflation of embedded objects (see Elastic::Model::Meta::Instance).
exporting the "has_mapping" function to allow you to customize the special "meta-fields" in the type mapping in ElasticSearch
has_mapping can be used to customize the special "meta-fields" (ie not attr/field-specific) in the type mapping. For instance:
has_mapping
has_mapping { _source => { compress => 1, includes => ['path1.*','path2.*'], excludes => ['path3.*'] }, _ttl => { enabled => 1, default => '2h' }, numeric_detection => 1, date_detection => 0, };
Warning: Use has_mapping with caution. Elastic::Model requires certain settings to be active to work correctly.
See the "Fields" section in Mapping and Root object type for more information about what options can be configured.
Elastic::Model::Role::Doc
Elastic::Model
Elastic::Meta::Trait::Field
Elastic::Model::TypeMap::Default
Elastic::Model::TypeMap::Moose
Elastic::Model::TypeMap::Objects
Elastic::Model::TypeMap::Structured
Elastic::Model::TypeMap::ES
Elastic::Model::TypeMap::Common
Clinton Gormley <drtech@cpan.org>
This software is copyright (c) 2012 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.
To install Elastic::Model, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Elastic::Model
CPAN shell
perl -MCPAN -e shell install Elastic::Model
For more information on module installation, please visit the detailed CPAN module installation guide.