2017 © Pedro Peláez
 

symfony-bundle elasticsearch-php-client-bundle

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 5.0

image

ulff/elasticsearch-php-client-bundle

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 5.0

  • Wednesday, March 7, 2018
  • by ulff
  • Repository
  • 3 Watchers
  • 2 Stars
  • 9,387 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 20 Versions
  • 2 % Grown

The README.md

ElasticsearchPhpClientBundle

Setting up bundle

Version Matrix

You need to match your version of Elasticsearch to the appropriate version of this library., (*1)

Bundle Version Elasticsearch Version
2.0 5.0
1.0 >= 1.0, ⇐ 5.0

Step 1: Install bundle

Install bundle using composer:, (*2)

php composer.phar require "ulff/elasticsearch-php-client-bundle:2.0"

Enable the bundle in AppKernel.php:, (*3)

// app/AppKernel.php

public function registerBundles()
{
    $bundles = [
        // ...
        new Ulff\ElasticsearchPhpClientBundle\UlffElasticsearchPhpClientBundle(),
    ];

    // ...
}

Step 2: add bundle configuration

Add following configuration to config.yml:, (*4)

# app/config/config.yml

ulff_elasticsearch_php_client:
    elastic_host: "localhost"
    elastic_port: "9200"

Replace values with proper ones., (*5)

Usage

Client usage

Elasticsearch client is available as a service:, (*6)

$client = $this->get('ulff_elasticsearch_php_client.client');

Create new index:

$indexParams = new IndexParams('index-name', 'type-name', 'id');
$indexParams->setBody(['someField' => 'some value']);
$response = $client->index($indexParams);

Returns IndexResponse object., (*7)

Get document:

$getParams = new GetParams('index-name', 'type-name', 'id');
$response = $client->get($getParams);

Returns GetResponse object., (*8)

Delete document:

$deleteParams = new DeleteParams('index-name', 'type-name', 'id');
$response = $client->delete($deleteParams);

Returns DeleteResponse object., (*9)

Delete by query:

$deleteParams = new DeleteByQueryParams('index-name', 'type-name');
$deleteParams->setBody([
   'query' => [
       'match_all' => new \stdClass(),
   ]
]);
$response = $client->deleteByQuery($deleteParams);

Returns DeleteByQueryResponse object., (*10)

Make search query:

$searchParams = new SearchParams('index-name', 'type-name');
$searchParams->setBody([
    'query' => [
        'match' => [
            'someField' => 'some value'
        ]
    ]
]);
$response = $client->search($searchParams);

Update document:

$updateParams = new UpdateParams('index-name', 'type-name', 'id');
$updateParams->setBody(['someField' => 'some value']);
$response = $client->update($updateParams);

Returns UpdateResponse object., (*11)

Purger usage

Bundle offers a possibility to purge whole index (by deleting and recreating empty). This can be useful e.g. for testing purposes., (*12)

There is a separate ulff_elasticsearch_php_client.purger service provided with the bundle. Following example shows how to purge index:, (*13)

$purger = $this->get('ulff_elasticsearch_php_client.purger');
$purger->purgeIndex('index_name');

Full documentation:

This bundle is a client for: * Elasticsearch-PHP 5.0 * Elasticsearch-PHP 2.0, (*14)

Follow the documentation there., (*15)

License

This bundle is licensed under the MIT license. Please, see the complete license in the bundle LICENSE file., (*16)

The Versions

07/03 2018

dev-master

9999999-dev

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 5.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

07/03 2018

2.3.0

2.3.0.0

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 5.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

30/08 2017

dev-develop

dev-develop

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 5.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

30/08 2017

2.2.5

2.2.5.0

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 5.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

30/08 2017

dev-search-parameters

dev-search-parameters

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 5.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

27/06 2017

dev-check-existence-before-delete

dev-check-existence-before-delete

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 5.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

27/06 2017

2.2.4

2.2.4.0

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 5.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

26/06 2017

2.2.3

2.2.3.0

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 5.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

23/06 2017

2.2.2

2.2.2.0

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 5.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

23/06 2017

dev-delete-by-query

dev-delete-by-query

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 5.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

26/05 2017

2.2.1

2.2.1.0

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 5.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

26/05 2017

dev-update-document

dev-update-document

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 5.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

26/05 2017

2.2.0

2.2.0.0

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 5.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

21/04 2017

dev-update-response

dev-update-response

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 2.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

21/04 2017

1.1.1

1.1.1.0

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 2.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

19/04 2017

dev-update-params

dev-update-params

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 2.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

19/04 2017

1.1.0

1.1.0.0

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 2.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

28/10 2016

2.1.0

2.1.0.0

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 5.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

28/10 2016

2.0.0

2.0.0.0

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 5.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php

12/07 2016

1.0.0

1.0.0.0

A very simple bundle for integrating Symfony2.x/3.x with Elasticsearch-PHP 2.0

  Sources   Download

MIT

The Requires

 

elasticsearch symfony2 bundle symfony3 php7 elastic php5 elasticsearch-php