NAME
Elastic::Doc - Adds Elastic::Model functionality to your object classes
VERSION
version 0.06
SYNOPSIS
Simple class definition
package MyApp::User;
use Elastic::Doc;
has 'name' => (
is => 'rw',
isa => 'Str'
);
no Elastic::Doc;
More complex class definition
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;
DESCRIPTION
Elastic::Doc prepares your object classes (eg MyApp::User
) for storage in ElasticSearch, by:
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
INTRODUCTION TO Elastic::Model
If you are not familiar with Elastic::Model, you should start by reading Elastic::Manual::Intro.
The rest of the documentation on this page explains how to use the Elastic::Doc module itself.
EXPORTED FUNCTIONS
has_mapping
has_mapping
can be used to customize the special "meta-fields" (ie not attr/field-specific) in the type mapping. For instance:
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.
SEE ALSO
AUTHOR
Clinton Gormley <drtech@cpan.org>
COPYRIGHT AND LICENSE
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.