PHP Classes

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

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 122 All time: 9,482 This week: 524Up
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
Picture of Mostafa Abd-El-Hamid
  Performance   Level  
Name: Mostafa Abd-El-Hamid <contact>
Classes: 23 packages by
Country: Egypt Egypt
Age: 40
All time rank: 5595 in Egypt Egypt
Week rank: 214 Up2 in Egypt Egypt Up
Innovation award
Innovation award
Nominee: 5x

Documentation

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 (3)  
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 (3)  /  ElasticSearch  
File Role Description
Files folder imageSeeder (1 file)

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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:122
This week:0
All time:9,482
This week:524Up