PHP Classes
elePHPant
Icontem

PHP ElasticSearch Bulk Insert: Insert many record values at once in ElasticSearch

Recommend this page to a friend!
  Info   View files Documentation   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2018-07-01 (1 year ago) RSS 2.0 feedNot yet rated by the usersTotal: 104 This week: 1All time: 9,154 This week: 315Up
Version License PHP version Categories
elastic-search-bulk 1.0.0Free For Educatio...7Searching, Web services, PHP 7
Description Author

This class can insert many record values at once in ElasticSearch.

It can connect to one ElasticSearch server instance and takes an array of data values to insert in a given ElasticSearch index.

The class takes the array and splits it in chunks of configurable size, so it can insert the whole data array sending multiple requests to the ElasticSearch server.

The class can also connect to one or more possible server instances, so it can fallback to another server when the first one is not available for some reason.

Innovation Award
PHP Programming Innovation award nominee
July 2018
Number 5
ElasticSearch is a well know search engine software that can associate data documents with keys that are used for performing fast searches.

Often applications need to store in ElasticSearch large amounts of data to be searched.

This package provides a solution to reduce the time to insert large data record sets in an ElasticSearch server instance.

Manuel Lemos
  Performance   Level  
Name: Mostafa Abd-El-Hamid <contact>
Classes: 23 packages by
Country: Egypt Egypt
Age: 35
All time rank: 5914 in Egypt Egypt
Week rank: 86 Up1 in Egypt Egypt Up
Innovation award
Innovation award
Nominee: 5x

 

Details

elasticsearchbulkinsertion (Future Mode)

Elastic Search Bulk Insertion Library

This class will seed the data into elastic search database using async requests and a PHP library called elasticsearch/elasticsearch

Installation:

composer require mosta/bulkinsertion

TODO:

1) Install elastic search library using composer:

     composer require elasticsearch/elasticsearch

2) Set the host and port number if needed

3) Set the memory limit of the execution of the function

4) Put the index name which is equivalent to database name in SQL

5) Put the type which is equivalent to the table name in SQL

6) Put the chunk size which is going to be the number of records

 elastic search will insert for each iteration
 This will affect the performance of the machine you will be using
 and elastic search machine.
 

7) Pass the data you want to insert into elastic search

## Example:

  <?php
  
  use ElasticSearch\Seeder;
  
  $seeder = new ElasticSeeder;
  
  $seeder->setHosts([
    'host' => '0.0.0.0',
    'port' => '9200'
  ]);
  
  $seeder->setMemoryLimit('2048M');
  
  $seeder->setIndexName('my_index');
  
  $seeder->setType('my_type');
  
  $seeder->setUpsertMode(TRUE);
  
  $seeder->setChunkSize(100);
  
  $seeder->run([
    'dataKey1' => 'dataValue1',
    'dataKey2' => 'dataValue2'
  ]);
  Files folder image Files  
File Role Description
Files folder imageElasticSearch (1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  ElasticSearch  
File Role Description
Files folder imageSeeder (1 file)

  Files folder image Files  /  ElasticSearch  /  Seeder  
File Role Description
  Plain text file ElasticSeeder.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:104
This week:1
All time:9,154
This week:315Up