| 302 | |
| 303 | template<typename T> |
| 304 | void es_objects_plugin_impl::prepareTemplate( |
| 305 | const T& blockchain_object, const es_objects_plugin_impl::plugin_options::object_options& opt ) |
| 306 | { |
| 307 | fc::mutable_variant_object bulk_header; |
| 308 | bulk_header["_index"] = _options.index_prefix + opt.index_name; |
| 309 | if( !is_es_version_7_or_above ) |
| 310 | bulk_header["_type"] = "_doc"; |
| 311 | if( !opt.store_updates ) |
| 312 | { |
| 313 | bulk_header["_id"] = string(blockchain_object.id); |
| 314 | } |
| 315 | |
| 316 | fc::variant blockchain_object_variant; |
| 317 | fc::to_variant( blockchain_object, blockchain_object_variant, GRAPHENE_NET_MAX_NESTED_OBJECTS ); |
| 318 | fc::mutable_variant_object o( utilities::es_data_adaptor::adapt( blockchain_object_variant.get_object(), |
| 319 | _options.max_mapping_depth ) ); |
| 320 | |
| 321 | o["object_id"] = string(blockchain_object.id); |
| 322 | o["block_time"] = block_time; |
| 323 | o["block_number"] = block_number; |
| 324 | |
| 325 | string data = fc::json::to_string(o, fc::json::legacy_generator); |
| 326 | |
| 327 | auto prepare = graphene::utilities::createBulk(bulk_header, std::move(data)); |
| 328 | std::move(prepare.begin(), prepare.end(), std::back_inserter(bulk_lines)); |
| 329 | |
| 330 | approximate_bulk_size += bulk_lines.back().size(); |
| 331 | |
| 332 | send_bulk_if_ready(); |
| 333 | } |
| 334 | |
| 335 | void es_objects_plugin_impl::send_bulk_if_ready( bool force ) |
| 336 | { |
no test coverage detected