PHP Classes
elePHPant
Icontem

File: README.md

Recommend this page to a friend!
  Classes of Mostafa Abd-El-Hamid  >  PHP ElasticSearch Bulk Insert  >  README.md  >  Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP ElasticSearch Bulk Insert
Insert many record values at once in ElasticSearch
Author: By
Last change: Update README.md
Update README.md
Update README.md
Update README.md
Update README.md
Date: 10 months ago
Size: 1,402 bytes
 

Contents

Class file image Download

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'
  ]);