GitXplorerGitXplorer
k

ElasticSearchX-Model-Generator

public
1 stars
0 forks
1 issues

Commits

List of commits on branch master.
Unverified
182f3fb25c51d2fbb1982d79ee42606a0dd873ba

Use SingleEncoding

kkentfredric committed 11 years ago
Unverified
c20d8d8087d1c41f0a7aa46613373e876d2ac3ef

Enable branch reset and master xdeps

kkentfredric committed 11 years ago
Unverified
f92c6752127eac891c52260c3f099156d0000291

Synchronise git subtree maint-travis-ci

kkentfredric committed 11 years ago
Unverified
da3c3914b034f8ee204418fb9554432bdea51f4e

Allow failures on extra-test branches

kkentfredric committed 11 years ago
Unverified
bc3dfb06141a82dcc580e60c71437db57e05ea09

Synchronise git subtree maint-travis-ci

kkentfredric committed 11 years ago
Unverified
92bb0e7e8835d95fe0888abc27fc8a7ee7dc8447

Short Circuit properly

kkentfredric committed 11 years ago

README

The README file for this repository.

NAME

ElasticSearchX::Model::Generator - Create a suite of ESX::Model classes from an existing mapping.

VERSION

version 0.1.8

SYNOPSIS

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();
}

DESCRIPTION

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.

EXPORTS

generate_model

this is just a sugar syntax for ESX:M:G->new() you can elect to import to make your code slightly shorter.

METHODS

index_names

@names = $esmg->index_names

returns the names of all indexes specified in the _mapping

index

$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.

type_names

@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.

type

$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

property_names

@names = $esmg->property_names( $index, $type )

properties

$properties = $esmg->properties( $index, $type )

property

$property = $esmg->property( $index, $type, $propertyname )

documents

@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.

ATTRIBUTES

mapping_url

rw, required

base_dir

rw, required

generator_base_class

rw, default: ElasticSearchX::Model::Generator

generated_base_class

rw, default: MyModel

document_generator_class

lazy

attribute_generator_class

lazy

typename_translator_class

lazy

document_generator

lazy

attribute_generator

lazy

typename_translator

lazy

PRIVATE ATTRIBUTES

_mapping_content

lazy

_ua

lazy

_mapping_data

lazy

PRIVATE METHODS

_build__ua

returns an HTTP::Tiny instance.

_build_document_generator_class

generator_base_class + '::DocumentGenerator'

_build_document_generator

returns an instance of $document_generator_class

_build_attribute_generator_class

generator_base_class + '::AttributeGenerator'

_build_attribute_generator

returns an instance of $attribute_generator_class

_build_typename_translator_class

generator_base_class + '::TypenameTranslator'

_build_typename_translator

returns an instance of $typename_translator_class

_build__mapping_content

returns the content of the URL at mapping_url

_build__mapping_data

returns the decoded data from JSON stored in _mapping_content

AUTHOR

Kent Fredric kentfredric@gmail.com

COPYRIGHT AND LICENSE

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.