BenchmarkAnything-Storage-Backend-SQL
view release on metacpan or search on metacpan
lib/BenchmarkAnything/Storage/Backend/SQL.pm view on Meta::CPAN
=head3 json_false
Auxiliary function for Elasticsearch JSON data.
=head2 Elasticsearch support
=head3 Config
You can pass through a config entry for an external search engine
(currently only Elasticsearch) to the constructor:
my $or_bench = BenchmarkAnything::Storage::Backend::SQL->new({
dbh => $or_dbh,
searchengine => {
elasticsearch =>
#
# which index/type to use
index => "myapp",
type => "benchmarkanything",
#
# queries use the searchengine
enable_query => 1,
#
# should each single added value be stored immediately
# (maybe there is another bulk sync mechanism)
index_single_added_values_immediately => 1,
#
# which nodes to use
nodes => [ 'localhost:9200' ],
#
# (OPTIONAL)
# Your additional application specific mappings, used when
# index is created.
#
# WARNING: You are allowed to overwrite the pre-defined
# defaults for the built-in fields (NAME, VALUE, VALUE_ID,
# UNIT, CREATED) as it is a RIGHT_PRECEDENT hash merge with
# your additional_mappings on the right side. So if you
# touch the internal fields you better know what you are
# doing.
additional_mappings => {
# static key <properties>
properties => {
# field
tapper_report => {
type => long,
},
tapper_testrun => {
type => long,
},
tapper_testplan => {
type => long,
},
},
},
},
});
With such a config and an already set up Elasticsearch you can use the
lib as usual but it is handling all things transparently behind the
scenes to index and query the data with Elasticsearch. The relational
SQL storage is still used as the primary storage.
=head3 Index
When C<index_single_added_values_immediately> is set, every single
added entry is fetched right after insert (to get all transformations
and added metadata) and sent to elasticsearch for index.
Please note, this immediate indexing adds an overhead to insert
time. You could as well switch-off this setting and take care of
indexing the data at another time. Then again, for instance the
C<::Frontend::HTTP> already takes care of bulk-adding new data
asynchronously, so the overhead should be hidden in there, so just
switch-on the feature and don't worry too much.
=head3 Search
When C<enable_query> is set, the BenchmarkAnything queries are
transformed into corresponding Elasticsearch queries, sent to
Elastisearch, and the result is taken directly from its answers.
=head1 AUTHOR
Roberto Schaefer <schaefr@amazon.com>
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2020 by Amazon.com, Inc. or its affiliates.
This is free software, licensed under:
The (two-clause) FreeBSD License
=cut
( run in 1.888 second using v1.01-cache-2.11-cpan-5735350b133 )