use Dancer::Plugin::ElasticModel;
emodel->namespace('myapp')->index->create;
edomain('myapp')->create( user => { name => 'Joe Bloggs' });
my $results = eview('users)->search;
Easy access to your Elastic::Model-based application from within your Dancer apps.
plugins:
ElasticModel:
model: MyApp
global_scope: 0
request_scope: 1
es:
servers: es1.mydomain.com:9200
transport: http
views:
users:
domain: myapp
type: user
The model
should be the name of your model class (which uses Elastic::Model).
Any parameters specified in es
will be passed directly to "new()" in Search::Elasticsearch::Compat.
Optionally, you can predefine named views, eg the users
view above is the equivalent of:
$view = $model->view( domain => 'myapp', type => 'user' );
Scoping is not enabled by default.
If you want to automatically create a new scope at the beginning of each request, you can do so with:
request_scope: 1
The request scope is cleaned up at the end of the request.
You can also create a global scope which is not cleaned up until the application exits, with:
global_scope: 1
Objects that are loaded in the global scope will remain cached in memory until your application exits. This is useful only for big objects that seldom change. The only way to refresh the object is by restarting your application.
See Elastic::Manual::Scoping for more.
"emodel()" gives you access to the model that you have configured in your config.yml
file.
$domain = edomain('mydomain');
"edomain()" is a shortcut for:
$domain = emodel->domain('mydomain');
Access the views
that you predefined in your "CONFIG":
$users = eview('users')->search;
Or create a new view:
$users = eview(domain=>'myapp', type => 'user');
$users = eview->domain('myapp')->type('user');
You can find documentation for this module with the perldoc command.
perldoc Dancer::Plugin::ElasticModel
You can also look for information at: