/solarium

PHP Solr client library

Primary LanguagePHPOtherNOASSERTION

Solarium PHP Solr Client Library

What is Solarium?

Solarium is a PHP Solr client library that accurately model Solr concepts. Where many other Solr libraries only handle the communication with Solr, Solarium also relieves you of handling all the complex Solr query parameters using a well documented API.

Please see the docs for a more detailed description.

Requirements

Solarium 6.x only supports PHP 7.2 and up.

It's highly recommended to have Curl enabled in your PHP environment. However if you don't have Curl available you can switch from using Curl (the default) to a pure PHP based HTTP client adapter which works for the essential stuff but doesn't support things like parallel query execution.

Alternatively you can inject any PSR-18 compatible HTTP Client using the Psr18Adapter.

Getting started

The preferred way to install Solarium is by using Composer. Solarium is available on Packagist.

Example:

composer require solarium/solarium

Pitfall when upgrading from 3.x or 4.x or 5.x

Setting "timeout" as "option" in the HTTP Client Adapter is deprecated since Solarium 5.2.0 because not all adapters could handle it. The adapters which can handle it now implement the TimeoutAwareInterface and you need to set the timeout using the setTimeout() function after creating the adapter instance.

In order to fix some issues with complex queries using local parameters solarium 6 destinguishs between query parameters and local parameters to be embedded in a query. Solarium 5.2 already informed you about the deprecation of some parameter names which are in fact local parameters. Solarium doen't convert them magically anymore. Local parameter names now have to be prefixed with local_ if set as option of a constructor.

Solarium 5:

$categoriesTerms = new Solarium\Component\Facet\JsonTerms(['key' => 'categories', 'field' => 'cat', 'limit'=>4,'numBuckets'=>true]);

Solarium 6:

$categoriesTerms = new Solarium\Component\Facet\JsonTerms(['local_key' => 'categories', 'field' => 'cat', 'limit'=>4,'numBuckets'=>true]);

See https://lucene.apache.org/solr/guide/local-parameters-in-queries.html for an introduction about local parameters.

Pitfall when upgrading from 3.x or 4.x

In the past, the V1 API endpoint solr was not added automatically, so most users set it as path on the endpoint. This bug was discovered with the addition of V2 API support. In almost every setup, the path has to be set to / instead of /solr with this release!

For the same reason it is a must to explicit configure the core or collection.

So an old setting like

'path' => '/solr/xxxx/'

has to be changed to something like

'path' => '/',
'collection' => 'xxxx',

Run the examples

To run the examples read through the Example code section of https://solarium.readthedocs.io/en/stable/getting-started/

More information

Continuous Integration status

  • Run Tests
  • codecov
  • SensioLabsInsight
  • Total Downloads