Giter Site home page Giter Site logo

nelmiosolariumbundle's Introduction

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 in config.yml:

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.

nelmiosolariumbundle's People

Contributors

acasademont avatar adrienbrault avatar benjamindulau avatar bpolaszek avatar igorw avatar joekre avatar keesschepers avatar m0ppers avatar marek-binkowski-sim avatar royopa avatar rubinum avatar seldaek avatar shieldo avatar smoench avatar smolowik avatar uwej711 avatar vierbergenlars avatar volkan avatar wiistriker avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.