The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

NAME

Elastic::Model::Meta::Class::Model - A meta-class for Models

VERSION

version 0.52

DESCRIPTION

Holds static information about your model: namespaces and their types, and char_filters, tokenizers, filters and analyzers for analysis.

You shouldn't need to use this class directly. Everything you need should be accessible via Elastic::Model or Elastic::Model::Role::Model.

METHODS

is_default()

$bool = $meta->is_default($type => $name);

Returns true if $name is a $type (analyzer, tokenizer, filter, char_filter) available in Elasticsearch by default.

Default analyzers

standard, simple, whitespace, stop, keyword, pattern, snowball, and the language analyzers: arabic, armenian, basque, brazilian, bulgarian, catalan, chinese, cjk, czech, danish, dutch, english, finnish, french, galician, german, greek, hindi, hungarian, indonesian, italian, latvian, norwegian, persian, portuguese, romanian, russian, spanish, swedish, thai, turkish

Default tokenizers

edge_ngram, keyword, letter, lowercase, ngram, path_hierarchy, pattern, standard, uax_url_email, whitespace

Default token filters

asciifolding, dictionary_decompounder, edge_ngram, elision, hyphenation_decompounder, icu_collation, icu_folding, icu_normalizer, kstem, length, lowercase, ngram, pattern_replace, phonetic, porterStem, reverse, shingle, snowball, standard, stop, synonym, trim, truncate, unique, word_delimiter

Default character filters

html_strip, mapping

analysis_for_mappings()

$analysis = $meta->analysis_for_mappings($mappings)

Used to generate the analysis settings for an index, based on which analyzers are used in the mappings for all types in the index.

wrapped_class_name()

$new_class = $meta->wrapped_class_name($old_class);

Generates a semi-anonymous classname with the format Elastic::Model::__WRAPPED_::$n

ATTRIBUTES

namespaces

\%namespaces = $meta->namespaces;
\%namespace = $meta->namespace($name);
$bool = $meta->has_namespace($name);
@names = $meta->all_namespaces;

A hash ref containing all namespaces plus their configuration, eg:

{
myapp => {
types => {
user => 'MyApp::User'
}
}
}

unique_index

$index = $meta->unique_index

The name of the index where unique keys will be stored, which defaults to unique_key. A different value can be specified with has_unique_index.

See Elastic::Manual::Attributes::Unique for more.

analyzers

\%analyzers = $meta->analyzers;
\%analyzer = $meta->analyzer($name);
$bool = $meta->has_analyzer($name);
@names = $meta->all_analyzers;

A hash ref containing all analyzers plus their configuration, eg:

{
my_analyzer => {
type => 'custom',
tokenizer => 'standard',
filter => ['lower']
}
}

tokenizers

\%tokenizers = $meta->tokenizers;
\%tokenizer = $meta->tokenizer($name);
$bool = $meta->has_tokenizer($name);
@names = $meta->all_tokenizers;

A hash ref containing all tokenizers plus their configuration, eg:

{
my_tokenizer => {
type => 'pattern',
pattern => '\W'
}
}

filters

\%filters = $meta->filters;
\%filter = $meta->filter($name);
$bool = $meta->has_filter($name);
@names = $meta->all_filters;

A hash ref containing all filters plus their configuration, eg:

{
my_filter => {
type => 'edge_ngram',
min_gram => 1,
max_gram => 20
}
}

char_filters

\%char_filters = $meta->char_filters;
\%char_filter = $meta->char_filter($name);
$bool = $meta->has_char_filter($name);
@names = $meta->all_char_filters;

A hash ref containing all char_filters plus their configuration, eg:

{
my_char_filter => {
type => 'mapping',
mappings => ['ph=>f','qu=>q']
}
}

AUTHOR

Clinton Gormley <drtech@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 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.