PHPackages                             neelkanthk/esloader - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. neelkanthk/esloader

ActivePackage[Search &amp; Filtering](/categories/search)

neelkanthk/esloader
===================

A lighweight PHP package for indexing data into Elasticsearch index.

0.0.2(6y ago)510MITPHP

Since Aug 11Pushed 6y ago1 watchersCompare

[ Source](https://github.com/neelkanthk/EsLoader)[ Packagist](https://packagist.org/packages/neelkanthk/esloader)[ RSS](/packages/neelkanthk-esloader/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (5)Versions (4)Used By (0)

[![](https://camo.githubusercontent.com/3d2dc6a13369072d8eaa0b601cd0aa564f3357e533dea16b5d1167cbc3ff9c64/68747470733a2f2f692e6962622e636f2f3677727948476b2f65736c6f616465722d6c6f676f2e706e67)](https://camo.githubusercontent.com/3d2dc6a13369072d8eaa0b601cd0aa564f3357e533dea16b5d1167cbc3ff9c64/68747470733a2f2f692e6962622e636f2f3677727948476b2f65736c6f616465722d6c6f676f2e706e67)

EsLoader is a lighweight PHP package for indexing data from multiple sources into Elasticsearch index.

**Table of Contents**

### Features

[](#features)

- Simple and Easy 3 step integration.
- Supports CSV, XML and JSON files.
- Support for MongoDb and MySQL coming soon in next release.
- Indexes data quickly by leveraging the bulk indexing feature of Elasticsearch.
- Supports integration of AWS Elasticsearch Service.
- Fully configurable - Define your own index name, custom mapping and settings and even set the size of each batch request.

**NOTE 1: This package is developed and tested on PHP 7.x and Elasticsearch 6.x.**

**NOTE 2: This package uses `_doc` for the `_type` meta field of Elasticsearch document. This setting is not configurable. To know more read : [Removal of mapping types.](https://www.elastic.co/guide/en/elasticsearch/reference/6.7/removal-of-types.html "Removal of mapping types.")**

### Installation

[](#installation)

`$ composer require neelkanthk/esloader`

### Usage

[](#usage)

```
require __DIR__ . '/vendor/autoload.php';

use Neelkanthk\EsLoader\Core\EsLoader;

//1. Specify the path of file to be indexed.
$filePath = __DIR__ . "/data.csv";
//2. Load array of configurations.
$config = [
    "index" => "esloader",
    "doc_id_key" => NULL,
    "connection" => "local",
    "local" => [
        'host' => "localhost",
        'port' => "9200"
    ],
    "aws" => [
        'host' => "",
        'region' => "",
        'access_key' => "",
        'secret_key' => ""
    ],
    "mappings" => [
        "_doc" => [
            '_source' => [
                'enabled' => true
            ],
            "properties" => [
                "id" => ['type' => 'keyword'],
                "first_name" => ['type' => 'text'],
                "last_name" => ['type' => 'text'],
                "email" => ['type' => 'keyword'],
                "gender" => ['type' => 'keyword'],
                "points" => ['type' => 'integer']
            ]
        ],
    ],
    "settings" => [
        'number_of_shards' => 2,
        'number_of_replicas' => 0
    ],
    "batch_size" => 100
];
//3. Pass the file and configuration to the `EsLoader::load` method.
EsLoader::load($filePath, $config);
```

### Configuration

[](#configuration)

```
