Recommend this page to a friend!
  Classes of Mostafa Abd-El-Hamid  >  PHP ElasticSearch Bulk Insert  >  >  Download  
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
Date: 3 years ago
Size: 1,402 bytes


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


composer require mosta/bulkinsertion


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:

  use ElasticSearch\Seeder;
  $seeder = new ElasticSeeder;
    'host' => '',
    'port' => '9200'
    'dataKey1' => 'dataValue1',
    'dataKey2' => 'dataValue2'
For more information send a message to info at phpclasses dot org.