Elastic::Model::Domain - The domain (index or alias) where your docs are stored.
version 0.52
$domain = $model->domain('myapp');
$user = $domain->new_doc( user => \%args ); $user->save; # or: $user = $domain->create( user => \%args);
$user = $domain->get( $type => $id ); $user = $domain->try_get( $type => $id ); # return undef if missing
$bool = $domain->exists( $type => $id );
$uid = $domain->delete( $type => $id ); $user = $domain->try_delete( $type => $id ); # return undef if missing
$view = $domain->view(%args);
A "domain" is like a database handle used for CRUD (creating, updating or deleting) individual objects or documents. The $domain->name can be the name of an index or an index alias. A domain can only belong to a single namespace.
$domain->name
NOTE: If $domain->name is an alias, it can only point to a single index.
A $domain->name must be either the name of an index or of an index alias which points to a single index. The index or alias must exist, and must be known to the namespace.
The Elastic::Model::Namespace object to which this domain belongs.
$domain = $model->domain_class->new({ name => $domain_name, namespace => $namespace, });
Although documented here, you shouldn't need to call new() yourself. Instead you should use "domain()" in Elastic::Model::Role::Model:
new()
$domain = $model->domain($domain_name);
$doc = $domain->new_doc( $type => \%args );
new_doc() will create a new object in the class that maps to type $type, passing %args to new() in the associated class. For instance:
new_doc()
$type
%args
$user = $domain->new_doc( user => { id => 1, name => 'Clint', } );
$doc = $domain->create( $type => \%args );
This is the equivalent of:
$doc = $domain->new_doc( $type => \%args )->save();
$doc = $domain->get( $type => $id ); $doc = $domain->get( $type => $id, routing => $routing, ... );
Retrieves a doc of type $type with ID $id from index $domain->name or throws an exception if the doc doesn't exist. See "get_doc()" in Elastic::Model::Role::Store for more parameters which can be passed.
$id
$doc = $domain->try_get( $type => $id ); $doc = $domain->try_get( $type => $id, routing => $routing, ... );
Retrieves a doc of type $type with ID $id from index $domain->name or returns undef if the doc doesn't exist.
$bool = $domain->exists( $type => $id ); $bool = $domain->exists( $type => $id, routing => $routing, ... );
Checks if a doc of type $type with ID $id exists in index $domain->name. See "doc_exists()" in Elastic::Model::Role::Store for more parameters which can be passed.
$uid = $domain->delete( $type => $id ); $uid = $domain->delete( $type => $id, routing => $routing, ... );
Deletes a doc of type $type with ID $id from index $domain->name or throws an exception if the doc doesn't exist. See "delete_doc()" in Elastic::Model::Role::Store for more parameters which can be passed.
$uid = $domain->try_delete( $type => $id ); $uid = $domain->try_delete( $type => $id, routing => $routing, ... );
Deletes a doc of type $type with ID $id from index $domain->name or returns undef if the doc doesn't exist.
$view = $domain->view(%args)
Creates a view with the "domain" in Elastic::Model::View set to $domain->name. A view is used for searching docs in a $domain.
view
$domain
Clinton Gormley <drtech@cpan.org>
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.
To install Elastic::Model, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Elastic::Model
CPAN shell
perl -MCPAN -e shell install Elastic::Model
For more information on module installation, please visit the detailed CPAN module installation guide.