Giter Site home page Giter Site logo

nelmiosolariumbundle's Introduction

NelmioSolarium Bundle

Latest Version Total Downloads

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
    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 which 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();

Plugins

Solarium works with plugins. If you want to use your own plugins, you can register a plugin in the bundle configuration either with a service id or the plugin class:

nelmio_solarium:
    clients:
        default:
            plugins:
                test_plugin_service:
                    plugin_service: plugin _service_id
                test_plugin_classname:
                    plugin_class: Some\Plugin\TestPlugin

Overriding the Client class

To change the client class, you can set the client_class option:

nelmio_solarium:
    clients:
        default:
            client_class: Solarium\Core\Client

Customizing the HTTP Adapter used by the Client

If you need to customize the Adapter that is used by the Client to perform HTTP requests to Solr then you can use the adapter_service option to specify the ID of a symfony service to be used as an adapter:

nelmio_solarium:
    clients:
        default:
            adapter_service: 'my.custom.adapter.service'

HTTP Request timeout

If you are using the default adapter (Curl) and did not customize the adapter_service then you can use the adapter_timeout option to customize the timeout. Solarium uses a timeout of 5 seconds by default.

nelmio_solarium:
    clients:
        default:
            adapter_timeout: 10

Loadbalancer Plugin

Solarium ships with a loadbalancer plugin which can be configured via the load_balancer option on the client level.

Passing a list of endpoints will assign equal weights of 1 and randomly pick an endpoint for each request.

nelmio_solarium:
    endpoints:
        one:
            host: 192.168.1.2
        two:
            host: 192.168.1.3
        three:
            host: 192.168.1.4
    clients:
        default:
            load_balancer:
                enabled: true
                endpoints: [ one, two, three ] # will assign equal weights of 1

You can also assign different weights (integers >= 1) to the endpoints to have a more fine-grained control over the loadbalancing. There are also options to customize the blocked query types and the default endpoint to use for those queries.

nelmio_solarium:
    endpoints:
        one:
            host: 192.168.1.2
        two:
            host: 192.168.1.3
        three:
            host: 192.168.1.4
    clients:
        default:
            default_endpoint: two # the default endpoint to use for blocked query types 
            load_balancer:
                enabled: true
                blocked_query_types: [ 'select', 'update' ] # default is [ 'update' ]
                endpoints: 
                    one: 1
                    two: 2 # this endpoint will be used twice as often as the other two       
                    three: 1

Also see the Solarium documentation for the loadbalancer plugin: https://github.com/solariumphp/solarium/blob/master/docs/plugins.md#loadbalancer-plugin

License

Released under the MIT License, see LICENSE.

nelmiosolariumbundle's People

Contributors

acasademont avatar adrienbrault avatar benjamindulau avatar bpolaszek avatar dmaicher avatar harmstyler avatar igorw avatar ipf avatar joekre avatar m0ppers avatar royopa avatar rubinum avatar seldaek avatar shieldo avatar smoench avatar thepanz avatar uwej711 avatar vierbergenlars avatar volkan avatar wiistriker avatar

Stargazers

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

Watchers

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

nelmiosolariumbundle's Issues

connect through proxy with basic authentication

Hi, this is my configuration of the bundle connecting to solr with basic authentication enbled and everything works fine:

nelmio_solarium:
    endpoints:
        default:
            host: user:pass@solr_host
            core: solr_core
            scheme: http
            port: 8983
            path: /solr
            # timeout: 5
    clients:
        default:
            endpoints: [default]

how can i configure this to pass through a proxy if needed? cause i think it will be needed. thanks in advance!

add multiple endpoint for master/slave core.

when I add multiple solr server as endpoint and using a single solarium client to fire query on any solr server; I add replication master/slave to solr. for now I taste when the server for onecore(master or slave) is failed the client/solarium must use the available endpoint.

I get this ERROR:

Message: Solr HTTP error: HTTP request failed, Failed connect to 127.0.0.1:8983; No error
because i stop solr in port 8983 and solr is running at slave core in port 9000, in this case iam looking for to connect to localhost2 if localhost is not running. This is my code:

$config = array(
         "endpoint" => array("localhost" => array("host"=>"127.0.0.1",
         "port"=>"8983", "path"=>"/solr", "core"=>"master",),
         "localhost2" => array("host"=>"127.0.0.1",
         "port"=>"9000", "path"=>"/solr", "core"=>"slave",)

        ) );

    $client = new Solarium\Client($config);
            $ping = $client->createPing();
            $client->ping($ping,"localhost2");
            $client->getEndpoint();

when the key localhost is not running and the key localhost2 is runing in port 9000 i get this Message Solr HTTP error: HTTP request failed, Failed connect to 127.0.0.1:8983; No error

ANd the output of $client->getEndpoint();

object(Solarium\Client) {
    [protected] options => array(
        'adapter' => 'Solarium\Core\Client\Adapter\Curl',
        'endpoint' => array(
            'localhost' => array(
                'host' => '*****',
                'port' => '*****',
                'path' => '/solr',
                'core' => 'master'
            ),
            'localhost2' => array(
                'host' => '*****',
                'port' => '*****',
                'path' => '/solr',
                'core' => 'slave'
            )
        )
    )
    [protected] queryTypes => array(
        'select' => 'Solarium\QueryType\Select\Query\Query',
        'update' => 'Solarium\QueryType\Update\Query\Query',
        'ping' => 'Solarium\QueryType\Ping\Query',
        'mlt' => 'Solarium\QueryType\MoreLikeThis\Query',
        'analysis-document' => 'Solarium\QueryType\Analysis\Query\Document',
        'analysis-field' => 'Solarium\QueryType\Analysis\Query\Field',
        'terms' => 'Solarium\QueryType\Terms\Query',
        'suggester' => 'Solarium\QueryType\Suggester\Query',
        'extract' => 'Solarium\QueryType\Extract\Query',
        'get' => 'Solarium\QueryType\RealtimeGet\Query'
    )
    [protected] pluginTypes => array(
        'loadbalancer' => 'Solarium\Plugin\Loadbalancer\Loadbalancer',
        'postbigrequest' => 'Solarium\Plugin\PostBigRequest',
        'customizerequest' => 'Solarium\Plugin\CustomizeRequest\CustomizeRequest',
        'parallelexecution' => 'Solarium\Plugin\ParallelExecution\ParallelExecution',
        'bufferedadd' => 'Solarium\Plugin\BufferedAdd\BufferedAdd',
        'prefetchiterator' => 'Solarium\Plugin\PrefetchIterator',
        'minimumscorefilter' => 'Solarium\Plugin\MinimumScoreFilter\MinimumScoreFilter'
    )
    [protected] eventDispatcher => object(Symfony\Component\EventDispatcher\EventDispatcher) {
        [private] listeners => array()
        [private] sorted => array()
    }
    [protected] pluginInstances => array()
    [protected] endpoints => array(
        'localhost' => object(Solarium\Core\Client\Endpoint) {
            [protected] options => array(
                'host' => '*****',
                'port' => '*****',
                'scheme' => 'http',
                'path' => '/solr',
                'core' => 'master',
                'timeout' => (int) 5,
                'key' => 'localhost'
            )
        },
        'localhost2' => object(Solarium\Core\Client\Endpoint) {
            [protected] options => array(
                'host' => '*****',
                'port' => '*****',
                'scheme' => 'http',
                'path' => '/solr',
                'core' => 'slave',
                'timeout' => (int) 5,
                'key' => 'localhost2'
            )
        }
    )
    [protected] defaultEndpoint => 'localhost'
    [protected] adapter => null
}

PHPUnit errors in SF5 when injecting service

Hi,

I'm having some issues when using this bundle as a service in SF5. Service is configured as follows:

image

I need to use ServiceRegistry, so in my class I inject it:

image

But when passing tests, I'm having this output:

image

As you can see, tests are passing OK, but a lot of warnings are appearing.

Maybe I'm not decraring properly the service?

By the way, my yaml config file:

nelmio_solarium:
    endpoints:
        foo:
            scheme: http
            host: '%env(resolve:SOLR_HOST)%'
            port: 8983
            path: /
            core: Foo_all
        bar:
            scheme: http
            host: '%env(resolve:SOLR_HOST)%'
            port: 8983
            path: /
            core: Bar_all
    clients:
        foo:
            endpoints: [foo]
        bar:
            endpoints: [bar]

Thanks in advance and hope you're allright,

Javi

Solarium 5 support?

It would be nice to support Solarium 5.

As far as I can see the only issue should be the change for the default path?

https://github.com/nelmio/NelmioSolariumBundle/compare/master...dmaicher:solarium_5_compat?expand=1

I tried this on my project and it works without any other adjustments with solarium 5.0.3.
But that's because I don't set the path option on my project, so it uses the new default then.

So here my question: Should we support both Solarium < 5 and 5? If so maybe we can adjust the default config option (or maybe add a normalizer that strips out any /solr prefix) based on the used Solarium version? Not sure if there is a reliable way of detecting which Solarium version is used?

Or can we release a new major (4.0.0) that will only support Solarium 5?

I'm willing to contribute if we agree on an approach 😊

Fatal Error in Debug mode: setStopwatch()

When in debug mode (using app_dev.php):
Catchable Fatal Error: Argument 1 passed to Nelmio\SolariumBundle\Logger::setStopwatch() must be an instance of Symfony\Component\Stopwatch\Stopwatch, instance of Symfony\Component\HttpKernel\Debug\Stopwatch given, called in app/cache/dev/appDevDebugProjectContainer.php on line 3444 and defined in vendor/nelmio/solarium-bundle/Nelmio/SolariumBundle/Logger.php line 53

404 Exception if no endpoints are configured

Hey,

if no endpoints are configured in config.yml, a 404 Exception is thrown, stating that the request handler cannot be accessed. Reason: Not found. It would be more helpful if the programmer would be notified that no endpoints are defined (or that the config is missing). Would make the implementation more robust since it takes some time to find the error source.

Thanks in advance!

RFC: ClientRegistry

Hi,

any interest in adding a ClientRegistry similar to Doctrine's registry for managers? I need to access clients dynamically and would like to have a service that can be asked for a client given the name and that can also supply a list of the clients available. I will be happy to do a PR if there is a change for it to be merged ...

Cheers
Uwe

Improve load_balancer documentation

Looking in the it seems there is an option about load_balancer. Trying to have a 2 instances SOLR cluster i was interested but didn't succeed to make it work.

The stange thing is there is no doc about it. Can you add a small sample of such config ?

Create custom solarium client with DIC

Hi!
This bundle provide automatic client creation, but we can't configure other parameters of the Solarium client. For example, we can't register new plugin.

Instead using "syntax-sugar" provided with this class we can create class as regular service:

services:
    solarium.client.default:
        class: Solarium_Client

And we can do everything with this object.

Another benefit of this bundle: DataCollector. We may tag this custom services with some tag and add logger plugin. What do you think about such implementation?

Get an error from composer update

Hello I am using symfony 2.3 and get errors while updating composer.phar. How could I solve it? Thank you.

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - symfony/icu v1.2.0-RC1 requires lib-icu >=4.4 -> the requested linked library icu has the wrong version installed or is missing from your system, make sure to have the extension providing it.
    - symfony/icu v1.2.0-BETA1 requires lib-icu >=4.4 -> the requested linked library icu has the wrong version installed or is missing from your system, make sure to have the extension providing it.
    - symfony/icu v1.1.0-RC1 requires lib-icu >=3.8 -> the requested linked library icu has the wrong version installed or is missing from your system, make sure to have the extension providing it.
    - symfony/icu v1.1.0-BETA1 requires lib-icu >=4.0 -> the requested linked library icu has the wrong version installed or is missing from your system, make sure to have the extension providing it.
    - symfony/icu 1.2.x-dev requires lib-icu >=4.4 -> the requested linked library icu has the wrong version installed or is missing from your system, make sure to have the extension providing it.
    - symfony/icu 1.1.x-dev requires lib-icu >=3.8 -> the requested linked library icu has the wrong version installed or is missing from your system, make sure to have the extension providing it.
    - Conclusion: remove symfony/symfony 2.3.x-dev
    - Conclusion: don't install symfony/symfony 2.3.x-dev
    - Conclusion: don't install symfony/symfony v2.3.0-RC1
    - Installation request for nelmio/solarium-bundle 2.* -> satisfiable by nelmio/solarium-bundle[2.0.x-dev, v2.0.0, v2.0.1, v2.0.2].
    - Conclusion: don't install symfony/symfony v2.3.0-BETA2
    - symfony/symfony v2.3.0-BETA1 requires symfony/icu >=1.0,<2.0 -> satisfiable by symfony/icu[1.0.x-dev, 1.1.x-dev, 1.2.x-dev, v1.1.0-BETA1, v1.1.0-RC1, v1.2.0-BETA1, v1.2.0-RC1].
    - symfony/icu 1.0.x-dev requires symfony/intl >=2.3-RC,<3.0 -> satisfiable by symfony/symfony[2.3.x-dev, 2.4.x-dev, v2.3.0-RC1], symfony/intl[2.3.x-dev, 2.4.x-dev, v2.3.0-RC1].
    - symfony/icu 1.0.x-dev requires symfony/intl >=2.3-RC,<3.0 -> satisfiable by symfony/symfony[2.3.x-dev, 2.4.x-dev, v2.3.0-RC1], symfony/intl[2.3.x-dev, 2.4.x-dev, v2.3.0-RC1].
    - don't install symfony/intl 2.3.x-dev|don't install symfony/symfony v2.3.0-BETA1
    - don't install symfony/intl 2.4.x-dev|don't install symfony/symfony v2.3.0-BETA1
    - don't install symfony/intl v2.3.0-RC1|don't install symfony/symfony v2.3.0-BETA1
    - Can only install one of: symfony/symfony[v2.3.0-BETA1, 2.4.x-dev].
    - Installation request for symfony/symfony 2.3.* -> satisfiable by symfony/symfony[2.3.x-dev, v2.3.0-BETA1, v2.3.0-BETA2, v2.3.0-RC1].

Client load balancer plugin support changes breaks BC

Hello everyone,

The recent changes to the Configuration in the DI breaks BC, throwing a fatal error in Symfony 2.1, since canBeEnabled does not exist: 18223df

Errors:

PHP Fatal error:  Call to undefined method Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition::canBeEnabled() in /{path}/vendor/nelmio/solarium-bundle/Nelmio/SolariumBundle/DependencyInjection/Configuration.php on line 88

Fatal error: Call to undefined method Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition::canBeEnabled() in /{path}/vendor/nelmio/solarium-bundle/Nelmio/SolariumBundle/DependencyInjection/Configuration.php on line 88

v1.0.1 Tag?

There have been a lot of bug fixes and improvements to this bundle since its last tagged release. Can a fellow get a v1.0.1 tag? Thanks in advance.

Deprecated "Autowiring services based on the types"

Autowiring services based on the types they implement is deprecated since Symfony 3.3 and won't be supported in version 4.0. You should rename (or alias) the "solarium.client.default" service to "Solarium\Client" instead.

Profiler crashes when empty array parameter present

When query with parameter that's empty array is present, profiler will crash. To reproduce, create simple group query using Grouping Component and don't set "group.query" parameter (it's default empty array).
Crash occurs at line 61 of views/DataCollector/solarium.html.twig and is caused by using {% if value|keys %} condition at line 58 (which behaves wrong when provided array is emty).
I'm trying to figure out better way to ask twig if provided variable is array. If I'll manage to find it, I'll post PR.

Solr AddSort price

Hello i had a problem with price field.

method addSort('price_sort_index', 'asc') sort on string value not float value

schema.xml :

<field name="price" type="float" indexed="true" stored="true" multiValued="false" />
<field name="price_sort_index" type="float" indexed="true" stored="true" multiValued="false" />
<copyField source="price_sort_index" dest="alpha_price_only_sort" />

this method sort products by string values....
for example (price_sort_index results):
3,95 < 30 < 38 < 4
expected :
3,95 < 4 < 30 < 38

Tag merged pull request as stable

We're also encountering the issue mentioned in pull request #30. The code included with the request fixed the problem for us as well. Could we get a tagged stable release that includes this fix (i.e. 2.0.3, maybe) so that we don't need to use the dev-master/2.0.x-dev version in composer? It's forcing us to lower our composer minimum stability for an otherwise stable applications. Thanks.

Solarium 5.2 deprecations / compatibility

In Solarium 5.2 a few things changed:

  • new constructor signature for Client class. Old signature is deprecated now.
  • deprecated to set Adapter via FQCN on client
  • deprecated to set timeout on Endpoint

PHP8

How about support for the new version of PHP?

symfony 4.0 services

i got this error if i try to simply use the default solarium client:

The "solarium.client" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.

my code in a standard controller action:
$client = $this->get('solarium.client');

what can i do about this? thanks in advance.

Symfony 4 service loading.

After installation of version 3.x Service is not loaded. So i can not to inject service to subscriber and interpret insert to Selenium action.

Probably you forgot constructor.

Index: vendor/nelmio/solarium-bundle/NelmioSolariumBundle.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- vendor/nelmio/solarium-bundle/NelmioSolariumBundle.php	(date 1523379715000)
+++ vendor/nelmio/solarium-bundle/NelmioSolariumBundle.php	(date 1523379715000)
@@ -12,10 +12,21 @@
 namespace Nelmio\SolariumBundle;
 
 use Symfony\Component\HttpKernel\Bundle\Bundle;
+use Nelmio\ApiDocBundle\DependencyInjection\Compiler\ConfigurationPass;
+use Nelmio\ApiDocBundle\DependencyInjection\Compiler\TagDescribersPass;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
 
 /**
  * @author Igor Wiedler <[email protected]>
  */
 class NelmioSolariumBundle extends Bundle
 {
+    /**
+     * {@inheritdoc}
+     */
+    public function build(ContainerBuilder $container)
+    {
+        $container->addCompilerPass(new ConfigurationPass());
+        $container->addCompilerPass(new TagDescribersPass());
+    }
 }

New solariumphp/solarium version (3.5.0) related issue

Hi,

New SolariumPHP version (3.5.0) has been released on 2015-12-09 and it changed the class name of the abstract Plugin class :
Solarium\Core\Plugin\Plugin => Solarium\Core\Plugin\AbstractPlugin

Since the solarium/solarium requirement in composer.json is "~3.3", the new 3.5.0 is retrieved and the Logger plugin (Nelmio\ SolariumBundle\Logger) tries to extends the abstract Plugin with the "old" name, which results in an error.

For now, as a workaround, we forced the version of solarium/solarium with 3.4.1 in our application composer.json.

Logger does not distinguish between multiple clients

If You use more than one client, the initPluginType-Function of the Logger is called multiple times (one time for each client) and it registers itself multiple times for the preExecuteRequest and postExecuteRequest event. Thereby the postExecuteRequest event is triggered twice and on the second call the $this->currentRequest is null so it throws a \RuntimeException.
This bug was "enabled" since #58.

install through composer causes error

I am perhaps overlooking something simple, but what am I missing here...

composer.json:
...
"require": {
...
"nelmio/solarium-bundle": "dev-master",
...
...

app/config/config.yml:
imports:
- { resource: services.yml }

app/config/services.yml:
...
nelmio_solarium:
client:
class: Solarium_Client
adapter:
class: Solarium_Client_Adapter_Http
host: 127.0.0.1
port: 8983
path: /solr
timeout: 5
cores:
core0: core0

(produced by running 'composer update') vendor/composer/autoload_namespaces.php:
...
return array(
...
'Solarium' => $vendorDir . '/solarium/solarium/library/',
...
'Nelmio\SolariumBundle' => $vendorDir . '/nelmio/solarium-bundle/',
...
);
...

composer update output:
$ composer update
Loading composer repositories with package information
Updating dependencies
Generating autoload files

[Symfony\Component\DependencyInjection\Exception\RuntimeException]
The definition for "nelmio_solarium" has no class. If you intend to inject this service dynamically at runtime, please mark it as synthetic=true. If this is an abstract definition solely used by child definitions, please add abstract=true, otherwise specify a class to get rid of this error.

I change the services.yml config to the following:
nelmio_solarium:

client:

     class: Solarium_Client
    adapter:
        class: Solarium_Client_Adapter_Http
        host: 127.0.0.1
        port: 8983
        path: /solr
        timeout: 5
        cores:
            core0: core0

Everything runs as expected; I am left perplexed. Can someone provide some insight?

Call to undefined method get()

Hi all,
I'm new to Symfony and NelmioSolarium.
I have followed the steps of Installation Guide (added NelmioSolariumBundle to composer, updated composer, added NelmioSolariumBundle to AppKernel.php).

Then I have added these lines to app/config/config.yml:

nelmio_solarium: ~

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

But I get the error "call to undefined method get()" on this line:

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

I think I'm doing something wrong with my configuration.

Can you help me?
Thank you in advance!

Solarium Result is not serializable since 2.2.1

Hi, we are in our application caching results of the request to Solarium (in the Result class). And the Result class from Solarium library has reference to Solarium Client.

Since version 2.2.1 of the SolariumBundle the Client has reference to Symfony Event Dispatcher service, which has reference to Symfony DIC, which has again reference to the Event Dispatcher etc. As we are caching serialized instance of the Result class, these cyclic references make the serialization not working.

Do you propose any solution?

I should also note that at least for us this was serious and a bit surprising BC (as this change was released as patch version).

Thanks

Class 'Solarium_Client' not found

I get the following error
Fatal error: Class 'Solarium_Client' not found in /opt/lampp/htdocs/TwitterPolidoxacp2/app/cache/dev/appDevDebugProjectContainer.php on line 2015

I have following default config :

nelmio_solarium:
client:
class: Solarium_Client
adapter:
class: Solarium_Client_Adapter_Http
host: 127.0.0.1
port: 8983
path: /solr
timeout: 5
cores: ~

Any idea ?

Composer dependencies conflict

Got this error with composer require floriansemm/solr-bundle

Using version ^1.6 for floriansemm/solr-bundle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - floriansemm/solr-bundle v1.6.4 requires minimalcode/search ^1.0 -> satisfiable by minimalcode/search[1.0.0-RC1] but these conflict with your requirements or minimum-stability.
    - floriansemm/solr-bundle v1.6.3 requires minimalcode/search ^1.0 -> satisfiable by minimalcode/search[1.0.0-RC1] but these conflict with your requirements or minimum-stability.
    - floriansemm/solr-bundle v1.6.2 requires minimalcode/search ^1.0 -> satisfiable by minimalcode/search[1.0.0-RC1] but these conflict with your requirements or minimum-stability.
    - floriansemm/solr-bundle v1.6.1 requires minimalcode/search ^1.0 -> satisfiable by minimalcode/search[1.0.0-RC1] but these conflict with your requirements or minimum-stability.
    - floriansemm/solr-bundle v1.6 requires minimalcode/search ^1.0 -> satisfiable by minimalcode/search[1.0.0-RC1] but these conflict with your requirements or minimum-stability.
    - Installation request for floriansemm/solr-bundle ^1.6 -> satisfiable by floriansemm/solr-bundle[v1.6, v1.6.1, v1.6.2, v1.6.3, v1.6.4].

Symfony 3 Support

Currently, since composer.json has "symfony/framework-bundle": "~2.1" , we can't upgrade to Symfony 3.0.
Any plans on changing this requirement? If there are any obstacles for the upgrade, maybe we could help?

More than one client?

What if in project we need to work with two or more solr instancies (on various hosts\ports)

throw new \RuntimeException('Request already set');

I'm having an issue (since I've updated Solarium + Nelmio bundles) because of the following piece of code, located in Logger::preExecuteRequest() :

if (isset($this->currentRequest)) {
    // mop: hmmm not sure what happens when an exception is thrown :S lets be restrictive for the moment
    throw new \RuntimeException('Request already set');
}

My script have some kind of "retries" system to push the data to Solr : everytime it fails, it retries some time later until it has reach a retries limit.

Since the update, if there's a failure, the next time it tries to push I've got the mentioned exception thrown. Here a sample of my script :

$client = $this->getSolrClient();
$update = $client->createUpdate();

while (!empty($documents)) {

    // Prepare the data 
    // ...

    try {
        $client->update($update);

        // Tell the user it's working well
        $this->outputBlock('The data push was successful !', 'info', false);

        // Remove the data that have succeeded, so that the loop don't get infinite
        unset($documents[$index]);

    } catch (\Solarium\Exception\ExceptionInterface $e) {

        // Output the exception to the user
        $output->write(PHP_EOL);
        $this->outputBlock(
            'An Exception has been thrown during the Solr update for the data '.$index.' '.
            '(Code: '.$e->getCode().' / Message: '.$e->getMessage().').'.PHP_EOL.
            ' As it may happens for unknown reasons, we will try to update this data again later.',
            'error',
            false
        );

        // Increment the number of failed tries
        ++$nbFailedSolrPush;

        // Add this data to the ones that have failed
        ++$nbFailedPerCountry[$index];

        // Continue to try until we've reach the limit of tries allowed
        if ($nbFailedPerCountry[$index] < $maxFailedSolrPush) {
            continue;
        }
    }
}

The line in my code throwing the \RuntimeException is $client->update($update);.

@Seldaek What do you think ? Should we be less restrictive (remove the throw line in the bundle), or should I override your Logger class to get rid of the throw line for my "special" case ?

Thanks for your help.

Infinite loops with a Solarium log handler

Hi Jordi,

I'm currently writing a SolariumHandler for the Monolog library. The idea behind this is to convert each log entry to a Solarium Document, and at the end, commit an update to a solr core that will store the logs.

When using Symfony, if I use the SolariumHandler on the prod environment, everything works fine.
When using the SolariumHandler (which relies on NelmioSolariumBundle) on the dev environment, I've got a ServiceCircularReferenceException. I thinks this is because of the profiler : NelmioSolariumBundle logs each request made via Solarium, but the logger create some other requests that are also logged in the profiler... and this is infinite.

Do you have any advice to avoid this ?

Thanks,
Ben

Automatic persistence ?

Hi,

The question is simple : is there any way to persist an object into solr automatically ?

Something like annotations or even something in the configs files ?

And if not : are there any plan to make it ?

URI instead bunch of options in config

How do you think, should we create config parameter which can replace all host, port, path, etc.

For example:

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

Could be minimized to:

clients:
    default:
        uri: http://localhost:8983/solr/active

And inside Extension we can parse this string.

Now i have many solr instancies in my project and i need to create very large amount solr-related params in my parameters.yml!

'Solarium_Plugin_Abstract' not found

I have followed the instruction,
but got this:
Fatal error: Class 'Solarium_Plugin_Abstract' not found in D:\xampp....\vendor\bundles\Nelmio\SolariumBundle\Logger.php on line 12

both NelmioSolariumBundle and Solarium library installed.
Anybody has any idea?

Error: Unrecognized option "scheme" under "nelmio_solarium.endpoints.another"

nelmio_solarium:
    endpoints:
        default:
            scheme: http
            host: 10.4.2.103
            port: 8983
            path: /solr
            core: sicde_1
            timeout: 5
        another:
            scheme: http
            host: 10.4.2.103
            port: 8983
            path: /solr
            core: sicde_2
            timeout: 5
    clients:
        default:
            endpoints: [default, another]

InvalidConfigurationException in ArrayNode.php line 309:
Unrecognized option "scheme" under "nelmio_solarium.endpoints.another"

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.