ElasticSearchX::Model::Document::Trait::Attribute - Trait that extends the meta class of a document class
version 0.2.2
This defaults to 1 and marks the attribute as ElasticSearch property and thus will be added to the mapping. If you set this to 0 the attribute will act as a traditional Moose attribute.
1
0
Usually there is one property which also acts as id for the whole document. If there is no attribute with the id option defined ElasticSearch will assign a random id. This option can either be set to a true value or an arrayref. The former will make the value of the attribute the id. The latter will generate a SHA1 digest of the concatenated values of the attributes listed in the arrayref.
id
Only one attribute with the id option set can be present in a document.
Most of the time ElasticSearchX::Model::Document::Mapping will take care of this option and set the correct value based on the type constriant. In case it doesn't know what to do, this value will be used as the type for the attribute. Defaults to string.
string
The value of this property will be used as parent id. Since the parent id is stored in the _parent field, it is adviced to set "source_only" to 1 to prevent the field from being stored redundantly.
parent
_parent
A source_only attribute is not added to the type mapping, but it's value is included in the _source of a document. This is helpful if you don't want to index the value of this attribute in ElasticSearch, but still want to be able to access its value.
source_only
_source
has timestamp => ( timestamp => 1, is => 'ro' ); has timestamp => ( timestamp => { store => 1 }, is => 'ro' );
The attribute using this option will become the timestamp field (http://www.elasticsearch.org/guide/reference/mapping/timestamp-field.html).
has expire => ( ttl => 1, is => 'ro' ); $document->expire(86400) # document will expire in one day
Documents with a ttl field will set the _ttl property on the document in ElasticSearch. This will cause ElasticSearch to remove the document from the index automatically once the time to live has expired.
See http://www.elasticsearch.org/guide/reference/mapping/ttl-field.html.
The following attributes are passed through - as is - to the type mapping.
Defaults to yes.
yes
By default, properties are not dynamic. That means that fields that are unknown to the ElasticSearch mapping will not be indexed and no dynamic mapping will be auto generated. Since the mapping is generated by this module, there is no need to have the dynamic mapping enabled. If you want to enable it anyway, set this attribute to 1 value.
This will change the behaviour of HashRef attributes. Instead of deflating to a JSON string they will be stored as object in ElasticSearch.
HashRef
If this attribute or "index" is set to analyzed, the field is stored both analyzed and not analyzed. The not analyzed field can be accessed in queries by the field name. The analyzed field will have a .analyzed postfix if there is only one analyzer. If there are more than one analyzer, the .analyzed postfix refers to the first analyzer. For all other analyzers, its name is prefixed. This is done by using the multi_field feature of ElasticSearch.
analyzed
.analyzed
multi_field
By default, a field is not analyzed. That means the raw value is stored in the field. To add analyzed fields, either set "index" to analyzed or add an "analyzer". Set this to 0 if you don't want to store the not analyzed version of this field along with the analyzed.
This method is called by "mapping" in ElasticSearchX::Model::Document::Trait::Class and returns the mapping for this property as a HashRef.
Moritz Onken
This software is Copyright (c) 2015 by Moritz Onken.
This is free software, licensed under:
The (three-clause) BSD License
To install ElasticSearchX::Model, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ElasticSearchX::Model
CPAN shell
perl -MCPAN -e shell install ElasticSearchX::Model
For more information on module installation, please visit the detailed CPAN module installation guide.