2017 © Pedro Peláez
 

symfony-bundle php-client-bundle

A Elastification client bundle for Symfony2

image

elastification/php-client-bundle

A Elastification client bundle for Symfony2

  • Wednesday, January 20, 2016
  • by dawen
  • Repository
  • 0 Watchers
  • 0 Stars
  • 7,826 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 19 Versions
  • 0 % Grown

The README.md

Elastification Php Client Bundle

Build Status, (*1)


Config

Here is the configuration section for using the bundle, (*2)

Composer

Required in composer.json, (*3)

"elastification/php-client-bundle": "<1.0", (*4)

You have choose the right package for your transport. If you do not have installed thrift you should use guzzle, (*5)

"guzzlehttp/guzzle": "<7.0", (*6)

For Thrift transport, (*7)

"munkie/elasticsearch-thrift-php": "~1.4", (*8)

Don't forget to run composer update after you finished your composer.json, (*9)

AppKernel

In your app/config/AppHernel.php file you should activate the bundle by adding it to the array, (*10)

$bundles[] = new Elastification\Bundle\ElastificationPhpClientBundle\ElastificationPhpClientBundle();

App Config

In your app/config.yml or environment based you can add params (full config example):, (*11)

elastification_php_client:
  host: 127.0.0.1
  port: 9200
  protocol: http # http/thrift
  elasticsearch_version: 1.4.1
  search_repository_serializer_dic_id: elastification_php_client.serializer.native #default: elastification_php_client.serializer.native
  index_repository_serializer_dic_id: elastification_php_client.serializer.native #default: elastification_php_client.serializer.native
  document_repository_serializer_dic_id: elastification_php_client.serializer.native #default: elastification_php_client.serializer.native
  replace_version_of_tagged_requests: true #default: false
  logging_enabled: true
  profiler_enabled: true
  jms_serializer_class_map:
      - {index: my-index, type: my-type, class: AppBundle\Entity\MyEntity}

DIC

The registered DIC service id for the client is elastification_php_client, (*12)

Serializers

Native Serializer Service Id: elastification_php_client.serializer.native, (*13)

Jms Serializer Search Service Id: elastification_php_client.serializer.jms.search, (*14)

Jms Serializer Document Service Id: elastification_php_client.serializer.jms.document, (*15)

Repositories

Document Repository Serivce Id: elastification_php_client.repository.document, (*16)

Search Repository Serivce Id: elastification_php_client.repository.search, (*17)

Index Repository Serivce Id: elastification_php_client.repository.index, (*18)

Cat Repository Serivce Id: elastification_php_client.repository.cat, (*19)

Tagged request

If you want to register request services you can tag them with: elastification_php_client.request, (*20)


Versions


HowTo


Examples

For all examples should create some sample data in your elasticsearch., (*21)

Example for Search Repository

Performs a simple search. This code is an example that can be performed within an action of a controller., (*22)

/** @var SearchRepositoryInterface $searchRepo */
$searchRepo = $this->get('elastification_php_client.repository.search');

$query = array(
    'query' => array(
        'term' => array(
            'country' => array(
                'value' => 'germany'
            )
        )
    )
);

$searchRepo->search('my-index', 'my-type', $query);
var_dump($response->getHits());

Example for Document Repository

Gets a single document by id. This code is an example that can be performed within an action of a controller., (*23)

/** @var DocumentRepositoryInterface $docRepo */
$docRepo = $this->get('elastification_php_client.repository.document');

var_dump($docRepo->get('my-index', 'my-type', 'yourDocumentId'));

Examples for Index Repository

Checks if an index exists This code is an example that can be performed within an action of a controller., (*24)

/** @var IndexRepositoryInterface $indexRepo */
$indexRepo = $this->get('elastification_php_client.repository.index');
var_dump($indexRepo->exists('my-index'));

Creates an index This code is an example that can be performed within an action of a controller.`, (*25)

/** @var IndexRepositoryInterface $indexRepo */
$indexRepo = $this->get('elastification_php_client.repository.index');
var_dump($indexRepo->create('my-index'));

Example for simple search query with native serializer and no preconfigured requests

This code is an example that can be performed within an action of a controller., (*26)

/** @var Client $client */
$client = $this->get('elastification_php_client');

$request = new SearchRequest('my-index', 'my-type', new NativeJsonSerializer());
$response = $client->send($request);
//get the raw deserialized data
var_dump($response->getData()->getGatewayValue());
//for grabbing into the result do: $response->getData()['hits']

Example for tagging request services and using the request manager

Here is an example of a tagged request as service. The id parameter is optional. If this is not set, the request service id will be used. If the config parameter replace_version_of_tagged_requests is set to true. All registered requests will be parsed and set to the configured version., (*27)

request.getdocument:
    class: "Elastification\Client\Request\V090x\GetDocumentRequest"g
    arguments: ["my-index", "my-type", @elastification_php_client.serializer.native]
    public: false
    tags:
      - { name: elastification_php_client.request, id: get.service.text }

Using a registered request and perform a request. This code is an example that can be performed within an action of a controller., (*28)

$request = $client->getRequest('get.service.text');
$request->setId('yourDocumentId');
$response = $client->send($request);
var_dump($response->getData()->getGatewayValue());

ToDo

  • [x] create version for lib (0.1.0)
  • [x] create version for bundle
  • [] implement thrift config
  • [x] create jms serializer services
  • [x] create services for document repository
  • [x] create services for search repository
  • [x] create jms serializer service if jms serializer is available
  • [x] client lib: create jms document entity
  • [x] create document jms serializer service
  • [] php-client enable/disable response (debug) output ?

The Versions

20/01 2016

dev-master

9999999-dev http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

20/01 2016

0.5.2

0.5.2.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

15/01 2016

0.5.1

0.5.1.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

14/01 2016

0.5.0

0.5.0.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

22/12 2015

0.4.3

0.4.3.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

11/12 2015

0.4.2

0.4.2.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

11/12 2015

0.4.1

0.4.1.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

19/08 2015

0.4.0

0.4.0.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

08/07 2015

0.3.5

0.3.5.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

19/03 2015

0.3.4

0.3.4.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

15/03 2015

0.3.3

0.3.3.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

23/01 2015

0.3.2

0.3.2.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

23/01 2015

0.3.1

0.3.1.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

23/01 2015

0.3.0

0.3.0.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

22/01 2015

0.2.0

0.2.0.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

20/01 2015

0.1.3

0.1.3.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

14/01 2015

0.1.2

0.1.2.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

14/01 2015

0.1.1

0.1.1.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client

12/01 2015

0.1.0

0.1.0.0 http://www.elastification.de

A Elastification client bundle for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Wendlandt

elasticsearch symfony nosql elastification php-client