Skip to content

baldurrensch/NelmioSolariumBundle

 
 

Repository files navigation

NelmioSolariumBundle

About

The NelmioSolariumBundle provides integration with the solarium solr client.

Installation

Add NelmioSolariumBundle in your composer.json:

{
    "require": {
        "nelmio/solarium-bundle": "1.*"
    }
}

Download bundle:

$ php composer.phar update nelmio/solarium-bundle

Add the NelmioSolariumBundle to your AppKernel.php

public function registerBundles()
{
    $bundles = array(
        ...
        new Nelmio\SolariumBundle\NelmioSolariumBundle(),
        ...
    );
    ...
}

Basic configuration

Quick-start configuration:

nelmio_solarium: ~

Gives you a Solarium_Client service with default options (http://localhost:8983/solr)

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

Configure your client:

nelmio_solarium:
    clients:
        default:
            host: localhost
            port: 8983
            path: /solr
            core: active
            timeout: 5

Or with dsn:

nelmio_solarium:
    clients:
        default:
            dsn: http://localhost:8983/solr/active
            timeout: 5

Usage

        $client = $this->get('solarium.client');
        $select = $client->createSelect();
        $select->setQuery('foo');
        $results = $client->select($select);

For more information see the Solarium documentation.

Multiple clients

nelmio_solarium:
    clients:
        default:
            host: 192.168.1.2

        another:
            host: 192.168.1.3
    $defaultClient = $this->get('solarium.client');
    $anotherClient = $this->get('solarium.client.another');

You may also change default name with your own, but don't forget change default_client option if you want to get access to solarium.client service

nelmio_solarium:
    default_client: firstOne
    clients:
        firstOne:
            host: 192.168.1.2

        anotherOne:
            host: 192.168.1.3
    $firstOneClient = $this->get('solarium.client');
    //or
    $firstOneClient = $this->get('solarium.client.firstOne');

    $anotherOneClient = $this->get('solarium.client.anotherOne');

Overriding Classes

To change the adapter or client classes, you can set the client_class and adapter_class options:

nelmio_solarium:
    default_client: firstOne
    clients:
        default:
            client_class: Solarium_Client
            adapter_class: Solarium_Client_Adapter_Http

License

Released under the MIT License, see LICENSE.

About

Integration between Symfony2 and the Solarium Solr client.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%