ElasticSearchX::Model::Generator - Create a suite of ESX::Model classes from an existing mapping.
version 0.1.8
use ElasticSearchX::Model::Generator qw( generate_model ); my $instance = generate_model( mapping_url => 'http://someserver:port/path/_mapping', generated_base_class => 'MyModel', base_dir => "../path/to/export/dir/" ); for my $document ( $instance->documents ) { # Write the document to disk $document->write(); # Alternatively, load the generated document into memory avoiding writing to disk $document->evaluate(); }
ALPHA Code: This class at present only contains code sufficient for very simple package generation for use in creating a model from an existing mapping for the purposes of search.
this is just a sugar syntax for ESX:M:G->new() you can elect to import to make your code slightly shorter.
@names = $esmg->index_names
returns the names of all indexes specified in the _mapping
_mapping
$data = $esmg->index('') # If indexes are not in the data set $data = $esmg->index('cpan_v1') # if indexes are in the data set
Returns the data set nested under the specified index.
@names = $esmg->type_names( $index ) @names = $esmg->type_names('') # return all types defined in an index-free dataset. @names = $esmg->type_names('cpan_v1') # return all types in the cpan_v1 index.
$data = $esmg->type( $index, $type ) $data = $esmg->type( '', 'File' ) # get type 'File' from an index-free dataset $data = $esmg->type( 'cpan_v1', 'File' ) # get type 'File' from the cpan_v1 index
@names = $esmg->property_names( $index, $type )
$properties = $esmg->properties( $index, $type )
$property = $esmg->property( $index, $type, $propertyname )
@documents = $esmg->documents(); # all documents for all indexes @documents = $esmg->documents('cpan_v1'); # all documents for cpan_v1 @documents = $esmg->documents(''); # all documents for an index-free dataset.
rw, required
rw, default: ElasticSearchX::Model::Generator
rw, default: MyModel
lazy
returns an HTTP::Tiny instance.
HTTP::Tiny
generator_base_class + '::DocumentGenerator'
returns an instance of $document_generator_class
$document_generator_class
generator_base_class + '::AttributeGenerator'
returns an instance of $attribute_generator_class
$attribute_generator_class
generator_base_class + '::TypenameTranslator'
returns an instance of $typename_translator_class
$typename_translator_class
returns the content of the URL at mapping_url
mapping_url
returns the decoded data from JSON stored in _mapping_content
JSON
_mapping_content
Kent Fredric <kentfredric@gmail.com>
This software is copyright (c) 2013 by Kent Fredric <kentfredric@gmail.com>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install ElasticSearchX::Model::Generator, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ElasticSearchX::Model::Generator
CPAN shell
perl -MCPAN -e shell install ElasticSearchX::Model::Generator
For more information on module installation, please visit the detailed CPAN module installation guide.