Set up the solr service

Solr is highly reliable, scalable and fault tolerant, providing distributed indexing, replication and load-balanced querying, automated failover and recovery, centralized configuration, and more.

Solr uses the Lucene Java search library for full-text indexing and search. Your applications interact with Solr using HTTP POST (in JSON, XML, CSV, or binary formats) to index documents and using HTTP GET to retrieve search results back as JSON, XML, or a variety of other formats (Python, Ruby, PHP, CSV, binary, and so on). If you’re a programmer, try the Solr tutorial. Whether you’re a programmer or not, read the Solr FAQ.

More information about Solr.

We support Solr version 4.10.

Relationship

The format exposed in the $MAGENTO_CLOUD_RELATIONSHIPS follows:

{
    "solr": [
        {
            "path": "solr",
            "host": "192.0.2.55",
            "scheme": "solr",
            "port": 8080
        }
    ]
}

Usage example

In your .magento/services.yaml:

mysearch:
    type: solr:4.10
    disk: 1024

In your .magento.app.yaml:

relationships:
    solr: "mysearch:solr"

You can then use the service in a configuration file similar to the following:

$relationships = getenv("MAGENTO_CLOUD_RELATIONSHIPS");
if (!$relationships) {
  return;
}

$relationships = json_decode(base64_decode($relationships), TRUE);

foreach ($relationships['solr'] as $endpoint) {
  $container->setParameter('solr_host', $endpoint['host']);
  $container->setParameter('solr_port', $endpoint['port']);
}

Configuration

If you want to provide your own Solr configuration, you can add a core_config key in your .magento/services.yaml:

mysearch:
    type: solr:4.10
    disk: 1024
    configuration:
        core_config: !archive "<directory>"

The directory parameter points to the Magento vendor/magento/module-solr/conf directory, relative to the .magento directory, in the Git repository. This directory contains the Magento schema.