ElasticSearchX::Model::Document::Trait::Class - Trait that extends the meta class of a document class
A call to
$index->type('tweet') returns an instance of
Given a document class
the builder of this attribute tries to find a class named
If it's not found,
the default class ElasticSearchX::Model::Document::Set is used.
A custum set class (e.g.
MyModel::Tweet::Set) must inherit from ElasticSearchX::Model::Document::Set.
MyClass::Tweet->meta->short_name; # tweet
short_name is used as name for the type. It defaults to the lowercased, last segment of the class name.
my $mapping = $document->meta->mapping;
Builds the type mapping for this document class. It loads all properties using "get_all_properties" and calls "build_property" in ElasticSearchX::Model::Document::Trait::Attribute.
$meta->add_property( name => ( is => 'ro', isa => 'Str' ) )
Add a property through the
Returns true if all properties were acutally loaded from storage or whether
ElasticSearchX::Model::Set/fields was used to return a partial result set.
id attribute, i.e. the attribute that has the
id option set. Returns undef if it doesn't exist.
parent attribute, i.e. the attribute that has the
parent option set. Returns undef if it doesn't exist.
Returns a list of all properties in the document class. An attribute is considered a property, if it does the ElasticSearchX::Model::Document::Trait::Attribute role. That means all attributes that don't have the
property option explicitly set to
Since this method is called quite often, the result is cached if the document class is immutable.
"put" in ElasticSearchX::Model::Document calls this method to get an HashRef of all properties and their values. Values are deflated if a deflator was specified (e.g. DateTime objects are deflated to an ISO8601 string).
This software is Copyright (c) 2012 by Moritz Onken.
This is free software, licensed under:
The (three-clause) BSD License