{"id":20329332,"url":"https://github.com/ddev/ddev-solr","last_synced_at":"2025-04-11T20:41:49.224Z","repository":{"id":176813805,"uuid":"656057518","full_name":"ddev/ddev-solr","owner":"ddev","description":"Apache Solr service for DDEV","archived":false,"fork":false,"pushed_at":"2025-02-11T18:33:50.000Z","size":334,"stargazers_count":10,"open_issues_count":3,"forks_count":8,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-25T16:51:20.243Z","etag":null,"topics":["ddev-get"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ddev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["ddev"],"custom":["https://www.paypal.com/donate/?hosted_button_id=MCNCSZHC7LHSQ","https://ddev.com/support-ddev/"]}},"created_at":"2023-06-20T07:16:56.000Z","updated_at":"2025-02-11T18:32:05.000Z","dependencies_parsed_at":"2023-11-26T09:25:38.400Z","dependency_job_id":"41435758-7d8a-43e0-9d36-cedde8c04136","html_url":"https://github.com/ddev/ddev-solr","commit_stats":null,"previous_names":["mkalkbrenner/ddev-solr","ddev/ddev-solr"],"tags_count":9,"template":false,"template_full_name":"ddev/ddev-addon-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddev%2Fddev-solr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddev%2Fddev-solr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddev%2Fddev-solr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddev%2Fddev-solr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddev","download_url":"https://codeload.github.com/ddev/ddev-solr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248478930,"owners_count":21110787,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ddev-get"],"created_at":"2024-11-14T20:10:12.444Z","updated_at":"2025-04-11T20:41:49.215Z","avatar_url":"https://github.com/ddev.png","language":"Shell","funding_links":["https://github.com/sponsors/ddev","https://www.paypal.com/donate/?hosted_button_id=MCNCSZHC7LHSQ","https://ddev.com/support-ddev/"],"categories":[],"sub_categories":[],"readme":"[![tests](https://github.com/ddev/ddev-solr/actions/workflows/tests.yml/badge.svg)](https://github.com/ddev/ddev-solr/actions/workflows/tests.yml) ![project is maintained](https://img.shields.io/maintenance/yes/2025.svg)\n\n# ddev-solr \u003c!-- omit in toc --\u003e\n\n- [What is ddev-solr?](#what-is-ddev-solr)\n- [Getting started](#getting-started)\n- [Create a collection](#create-a-collection)\n- [Solr command line client](#solr-command-line-client)\n- [Using alternate versions of Solr](#using-alternate-versions-of-solr)\n- [Add third party Solr modules and libraries](#add-third-party-solr-modules-and-libraries)\n- [Solarium](#solarium-php-client)\n- [Drupal and Search API Solr](#drupal-and-search-api-solr)\n    - [Installation steps](#installation-steps)\n- [What's the difference between this and ddev-drupal9-solr](#whats-the-difference-between-this-and-ddev-drupal9-solr)\n\n## What is ddev-solr?\n\nddev-solr provides Solr (Cloud) using a single Solr node, which is sufficient\nfor local development requirements.\n\n\u003e [!NOTE]\n\u003e Existing applications that have been developed with Solr Standalone instead of\n\u003e Cloud should still work with Cloud. They connect to a __collection__ instead a\n\u003e __core__ but they should not notice that.\n\nSolr Cloud provides a lot of APIs to manage your collections, cores, schemas\netc. Some of these APIs require a so-called \"trusted\" context. Solr therefore\nsupports different technologies for authentication and authorization. The\neasiest one to configure is \"Basic Authentication\". This DDEV service comes with\na simple pre-configured `security.json` to provide such a trusted context based\non basic authentication. It creates a single administrative account having full\naccess rights:\n\n- user: `solr`\n- password: `SolrRocks`\n\n## Getting started\n\n1. Install the add-on and restart:\n\n    ```shell\n    ddev add-on get ddev/ddev-solr \u0026\u0026 ddev restart\n    ```\n\nOnce up and running, access Solr's admin UI within your browser by opening\n`https://\u003cprojectname\u003e.ddev.site:8943`. For example, if the project is named\n\"myproject\" the hostname will be `https://myproject.ddev.site:8943`.\n\nThe admin UI is protected by basic authentication. The preconfigured admin\naccount in `security.json` is user `solr` using the password `SolrRocks`.\n\nTo access the Solr container from DDEV's web container, use  `http://solr:8983`.\n\n\n\n## Create a collection\n\nCreating collections require that the configset to be used by this collection\nhas been uploaded within a \"trusted context\". This is ensured if you use the\nadmin UI with the predefined admin account `solr` or if you use the solr command\nline client `ddev solr-zk`. If you use any other http client and the API, ensure\nthat you use basic authentocation with the prconfigured admin account\n`solr:SolrRocks`.\n\nThe PHP solarium library provides all required methods as well.\nSome frameworks like Drupal provide a full integration to manage your Solr\ncollections within the framework itself.\n\nFor backward compatibility to older ddev Solr integrations and legacy\napplications that just provide a Solr configset (sometimes simply called\n\"Solr config\"), there's a ddev specific convenient method, too:\nSimply copy a configset directory to `.ddev/solr/configsets/` and restart ddev.\nThat configset will automatically be uploaded (or updated) to Solr using a\ntrusted context and a corresponding collection with the same name will be\ncreated if it doesn't exist already.\n\n\u003e [!NOTE]\n\u003e Solr Cloud could be run on multiple nodes. Any node has its own core\n\u003e that holds your data. A collection is a set of cores distributed over several\n\u003e nodes. If you read some old documentation or the usage instruction of an old PHP\n\u003e application, it might talk about a \"core\". In that case you could simply replace\n\u003e the word \"core\" with \"collection\". Connecting to a collection on Solr Cloud\n\u003e behaves like connecting to a core on \"Solr standalone\".\n\u003e Some documentations or applications talk about an \"index\". That's also just a\n\u003e synonym for a collection.\n\n\u003e [!NOTE]\n\u003e For maximum compatibility with older applications that don't support\n\u003e basic authentication when connecting Solr, reading/searching from and updating\n\u003e documents within an \"index\" (collection) doesn't require basic authentication\n\u003e using this ddev integration. For sure you can use basic authentication but it is\n\u003e not a must. Just the admin UI requires it to ensure the \"trusted context\".\n\n## Solr command line client\n\nThe `solr` command line client is available as ddev command:\n```sh\nddev solr\n```\n\nThe `zk` command is usually executed as `solr zk -z \u003cHOST\u003e:\u003cPORT\u003e`. To ease its\nusage a convenient ddev command exists that uses preconfigured connection\nsettings. So the `-z` option can be omitted:\n```sh\nddev solr-zk\n```\n\nBoth commands are preconfigured to connect as user `solr` which is the admin\naccount.\n\n## Using alternate versions of Solr\n\nThis addon defaults to installing a preferred version of the [docker Solr image](https://hub.docker.com/_/solr), but can be configured to use a different version via environment variable (`$SOLR_BASE_IMAGE`).  For example, if you would like to install the latest Solr 8.11.x, follow the steps below:\n\n```bash\nddev addon get ddev/ddev-solr\n\n# Change image version as appropriate.\nddev dotenv set .ddev/.env.solr --solr-base-image=\"solr:8.11\"\n\n# remove old solr volume (if this is downgrade)\nddev stop\ndocker volume rm ddev-$(ddev status -j | docker run -i --rm ddev/ddev-utilities jq -r '.raw.name')_solr\n\n# rebuild solr image (required step)\nddev debug rebuild -s solr\n\nddev restart\n\n# confirm the new Solr version (expect a value something like 8.11.4)\nddev solr version\n```\n\n\n## Add third party Solr modules and libraries\n\nCopy third party Solr modules and libraries jar files into `.ddev/solr/lib/`.\nTo load and use them within a collection, add this line to your\ncollection's `solrconfig.xml`:\n```xml\n\u003clib dir=\"/opt/solr/modules/ddev/lib/\" regex=\".*\\.jar\" /\u003e\n```\n\n## Solarium PHP client\n\n[Solarium](https://github.com/solariumphp/solarium) is the leading Solr\nintegration library for PHP. It is used by the modules and integrations of many\nPHP frameworks and CMS like Drupal, Typo3, Wordpress, Symfony, Laravel, ...\nIf you build your own PHP application and want to use Solarium directly, here is\nan example of how to configure the connection in DDEV.\n\n```php\nuse Solarium\\Core\\Client\\Adapter\\Curl;\nuse Symfony\\Component\\EventDispatcher\\EventDispatcher;\n\n$adapter = new Curl();\n$eventDispatcher = new EventDispatcher();\n$config = [\n    'endpoint' =\u003e [\n        'localhost' =\u003e [\n            // Replace \u003cproject\u003e by your project's name:\n            'host' =\u003e 'solr',\n            'port' =\u003e 8983,\n            'path' =\u003e '/',\n            // Use your collection name here:\n            'collection' =\u003e 'techproducts',\n            'username' =\u003e 'solr',\n            'password' =\u003e 'SolrRocks',\n        )\n    )\n);\n\n$client = new Solarium\\Client($adapter, $eventDispatcher, $config);\n```\n\n## Drupal and Search API Solr\n\nSolr Cloud is the \\\"modern\\\" (and simplest) way to run Solr.  You need to configure a Search API server using Solr as backend and `Solr Cloud with Basic Auth` as its connector. Specify the username \"solr\" and password \"SolrRocks\" which are the pre-configured credentials for Basic Authentication in `.ddev/solr/security.json`.\n\nSolr requires a Drupal-specific configset for any collection to index Drupal's content. (In Solr Cloud \"collections\" are the equivalent to \"cores\" in classic Solr installations. Actually, in a big Solr Cloud installation a collection might consist of multiple cores across all Solr Cloud nodes.)\n\n\nStarting from Search API Solr module version 4.2.1 you don't need to define collections or configsets so you can safely ignore the \\\"Create a collection\\\" section in this documentation . You simply enable the `search_api_solr_admin` submodule which is part of the [Search API Solr module](https://www.drupal.org/project/search_api_solr). Then you create or update your \\\"collections\\\" at any time by clicking the \"Upload Configset\" button on the Search API server details page or use `drush` to do this with\n\n```\nddev drush --numShards=1 search-api-solr:upload-configset SEARCH_API_SERVER_ID\n```\n\nNote: `SEARCH_API_SERVER_ID` is the machine name of your Search API server.The number of \"shards\" should always be \"1\" as this local installation only runs a single Solr node.\n\n[!Note]. Use `solr` rather than  `localhost` for the name of the solr server in your search api configuration.  The Search API suggests `localhost` but that won't work with DDEV.\n\nFor step-by-step setup details with screenshots refer to [Drupal at your fingertips: Local Solr setup with Search API Solr](https://www.drupalatyourfingertips.com/development#local-solr-setup-with-search-api-solr).\n\n\n\n\n### Installation steps\n\n1. Enable the `search_api_solr_admin` module. (This submodule is included in Search API Solr \u003e= 4.2.1)\n2. Create a search server using the Solr backend and select `Solr Cloud with Basic Auth` as connector:\n   - HTTP protocol: `http`\n   - Solr node: `solr`\n   - Solr port: `8983`\n   - Solr path: `/`\n   - Default Solr collection: `techproducts` (You can define any name here. The collection will be created automatically.)\n   - Solr host context: `solr`\n   - Username: `solr`\n   - Password: `SolrRocks`\n3. On the server's \"view\" page click the `Upload Configset` button and check the \"Upload (and overwrite) configset\" checkbox.\n    ![images](images/upload-configset.png)\n4. Set the number of shards to `1`.\n5. Press `Upload`.\n\n## What's the difference between this and ddev-drupal9-solr\n\nddev-drupal9-solr provides Solr running in a the \"classic standalone\" mode using a single core. ddev-solr runs Solr in\nthe modern \"cloud\" mode (even if it just starts a single Solr node).\n\nRunning in cloud mode has several advantages. The biggest one from Drupal's perspective is that every time an update of\nthe search_api_solr module asks you to generate and deploy an updated configset, it is just a click in the UI or a\nsingle drush command instead of downloading and extracting a zip, copying the files to the ddev folder and restarting\nddev. This is possible because of the Configset API Solr Cloud provides.\n\nBut there are also more and more APIs and features, which are only available in combination with Solr Cloud and which\nare supported by solarium and search_api_solr:\n   - [Streaming Expressions](https://solr.apache.org/guide/solr/latest/query-guide/streaming-expressions.html)\n   - Collection API\n   - Updating files like stop words, compound words, protected words, NLP models, LTR models, ... on the the fly using\n     APIs\n   - ...\n\nAnother important difference of ddev-solr compared to ddev-drupal9-solr is, that ddev-solr configures Solr to be able to\nhandle NLP models. So DDEV could be used with [search_api_solr_nlp](https://www.drupal.org/project/search_api_solr_nlp).\n\nddev-solr supports third party Solr plugins/modules/libraries.\n\n**Contributed and maintained by [@mkalkbrenner](https://github.com/mkalkbrenner)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddev%2Fddev-solr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddev%2Fddev-solr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddev%2Fddev-solr/lists"}