Developed with love by KnpLabs Hire us for your project!
118

NelmioSolariumBundle

by nelmio

Integration between Symfony2 and the Solarium Solr client.

NelmioSolariumBundle

About

The NelmioSolariumBundle provides integration with the solarium
solr client.

Installation

Require the nelmio/solarium-bundle package in your composer.json and update your dependencies.

$ composer require 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 endpoints:

nelmio_solarium:
    endpoints:
        default:
            scheme: http
            host: localhost
            port: 8983
            path: /solr
            core: active
            timeout: 5
    clients:
        default:
            endpoints: [default]

Or with dsn:

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

If you only have one endpoint, the client section is not necessary

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 and endpoints

nelmio_solarium:
    endpoints:
        default:
            host: 192.168.1.2
        another:
            host: 192.168.1.3
    clients:
        default:
            endpoints: [default]
        another:
            endpoints: [another]
    $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
    endpoints:
        firstOne:
            host: 192.168.1.2
        anotherOne:
            host: 192.168.1.3
    clients:
        firstOne:
            endpoints: [firstOne]
        anotherOne:
            endpoints: [anotherOne]
    $firstOneClient = $this->get('solarium.client');
    //or
    $firstOneClient = $this->get('solarium.client.firstOne');

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

Starting from Solarium 3.x you can also have multiple endpoints within the same client

nelmio_solarium:
    endpoints:
        default:
            host: 192.168.1.2
        another:
            host: 192.168.1.3
    # if you are using all the endpoints, the clients section is not necessary
    clients:
        default:
            endpoints: [default, another]

You can also set wich is the default endpoint

nelmio_solarium:
    endpoints:
        default:
            host: 192.168.1.2
        another:
            host: 192.168.1.3
    clients:
        default:
            endpoints: [default, another]
            default_endpoint: another

You can combine both multiple client and endpoints too

nelmio_solarium:
    endpoints:
        one:
            host: 192.168.1.2
        two:
            host: 192.168.1.3
        three:
            host: 192.168.1.4
    clients:
        firstOne:
            endpoints: [one, two]
            default_endpoint: two
        secondOne:
            endpoints: [two, three]
            default_endpoint: three

Client registry

You can also use the service solarium.client_registry to access the clients you have configured using the names you have used in the configuration (with the example above):

    $registry = $this->get('solarium.client_registry');
    $firstOne = $registry->getClient('firstOne');
    $secondOne = $registry->getClient('secondOne');

or if you have configured a default client

    $registry = $this->get('solarium.client_registry');
    $default = $registry->getClient();

Overriding Classes

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

nelmio_solarium:
    clients:
        default:
            client_class: Solarium\Core\Client
            adapter_class: Solarium\Core\Client\Adapter\Http

License

Released under the MIT License, see LICENSE.

Copyright (c) 2011 Nelmio

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
nelmio_solarium:
default_client: default
endpoints:

# Prototype
name:
host: 127.0.0.1
port: 8983
path: /solr
core: ~
timeout: 5
clients:

# Prototype
name:
client_class: Solarium\Client
adapter_class: ~
endpoints: []
default_endpoint: ~
  • Update target version
    By Seldaek, 9 months ago
  • Merge pull request #48 from smoench/patch-1
    By Seldaek, 9 months ago
  • updated readme
    By smoench, 9 months ago
  • updated solarium version
    By smoench, 9 months ago
  • Support scheme option for endpoints
    By smoench, 9 months ago
  • Update install instructions
    By Seldaek, 10 months ago
  • Update target release and use PSR-4
    By Seldaek, 10 months ago
  • Update CHANGELOG.md
    By Seldaek, 10 months ago
  • Merge pull request #42 from uwej711/add_client_registry
    By Seldaek, 1 year ago
  • Merge pull request #44 from volkan/master
    By Seldaek, 1 year ago
  • Update README.md
    By , 1 year ago
  • Implement a client registry to access multiple clients by name
    By uwej711, 1 year ago
  • Merge pull request #40 from vierbergenlars/patch-1
    By Seldaek, 1 year ago
  • [DataCollector] Fix query duration in solarium.html.twig
    By vierbergenlars, 1 year ago
  • Merge pull request #39 from adrienbrault/patch-1
    By Seldaek, 1 year ago
  • Fix profiler issue with multiple facet.query
    By adrienbrault, 1 year ago
  • Merge pull request #37 from adrienbrault/sf21-fix
    By Seldaek, 1 year ago
  • Fix load balancer config with symfony 2.1
    By adrienbrault, 1 year ago
  • Merge pull request #35 from adrienbrault/load-balancer
    By Seldaek, 1 year ago
  • Add client load balancer plugin support
    By adrienbrault, 1 year ago
  • Update changelog
    By Seldaek, 2 years ago
  • Log failed requests instead of failing hard when a request happens after another request failed to complete, fixes #34
    By Seldaek, 2 years ago
  • Merge pull request #33 from pylebecq/profiler-query-links
    By Seldaek, 2 years ago
  • Fixed query links in the profiler.
    By Pierre-Yves LEBECQ, 2 years ago
  • Update changelog
    By Seldaek, 2 years ago
  • Merge pull request #30 from jasonroman/logger_fix
    By Seldaek, 2 years ago
  • implementing serializable interface and corresponding methods so Profiler does not try to serialize the entire logger
    By Jason Roman, 2 years ago
  • Update changelog
    By Seldaek, 2 years ago
  • Add support for user/pass in dsn configuration
    By Seldaek, 2 years ago
  • Merge pull request #29 from acasademont/issue_28
    By Seldaek, 2 years ago