NAME

ElasticSearchX::Model::Document::Trait::Attribute - Trait that extends the meta class of a document class

VERSION

version 0.0.5

ATTRIBUTES

property

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.

id

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.

Only one attribute with the id option set can be present in a document.

type

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.

parent

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 to be stored redundantly.

source_only

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.

PASS THROUGH ATTRIBUTES

The following attributes are passed through - as is - to the type mapping.

store

Defaults to yes.

boost

index

dynamic

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.

analyzer

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.

include_in_all

include_in_parent

include_in_root

term_vector

not_analyzed

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.

METHODS

build_id

build_property

This method is called by "mapping" in ElasticSearchX::Model::Document::Trait::Class and returns the mapping for this property as a HashRef.

AUTHOR

Moritz Onken

COPYRIGHT AND LICENSE

This software is Copyright (c) 2012 by Moritz Onken.

This is free software, licensed under:

The (three-clause) BSD License