PHPackages                             shopapps/scout-solr-engine - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. shopapps/scout-solr-engine

ActiveLibrary[Search &amp; Filtering](/categories/search)

shopapps/scout-solr-engine
==========================

An Apache Solr driver for laravel scout

1.0.16(2y ago)0157MITPHPPHP ^8.0|^8.1|^8.2

Since May 10Pushed 2y ago1 watchersCompare

[ Source](https://github.com/shopapps/laravel-scout-solr-engine)[ Packagist](https://packagist.org/packages/shopapps/scout-solr-engine)[ RSS](/packages/shopapps-scout-solr-engine/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (17)Used By (0)

Laravel Scout Apache Solr driver
================================

[](#laravel-scout-apache-solr-driver)

[![GitHub issues](https://camo.githubusercontent.com/aa2a463f77afa4659722c2e9ee3324f9e9d88e2cfbfbd22f5968743513a014c1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f4b6c61617369652f6c61726176656c2d73636f75742d736f6c722d656e67696e65)](https://github.com/Klaasie/laravel-scout-solr-engine/issues)[![Latest Stable Version](https://camo.githubusercontent.com/57974895ead503b42cda3bfa45ecc62c3feaca7b4ed6f67b40282dd98cb9fcc9/687474703a2f2f706f7365722e707567782e6f72672f6b6c61617369652f73636f75742d736f6c722d656e67696e652f76)](https://packagist.org/packages/klaasie/scout-solr-engine)[![License](https://camo.githubusercontent.com/ca696ed22a3a5050dd8d38a1da74c06815dab9a6e7bbf9bdf658b6fe89c0b856/687474703a2f2f706f7365722e707567782e6f72672f6b6c61617369652f73636f75742d736f6c722d656e67696e652f6c6963656e7365)](https://packagist.org/packages/klaasie/scout-solr-engine)[![PHP Version Require](https://camo.githubusercontent.com/94af317ff9632ee6ceb6aa086a7638ba05c5ecd5eaa7778453a214fffbc367d5/687474703a2f2f706f7365722e707567782e6f72672f6b6c61617369652f73636f75742d736f6c722d656e67696e652f726571756972652f706870)](https://packagist.org/packages/klaasie/scout-solr-engine)

This package provides a basic implementation of the Apache Solr search engine within Laravel Scout.

Installation
------------

[](#installation)

`composer require shopapps/scout-solr-engine`

config
------

[](#config)

This package provides a config file that can be modified using .env variables.
You can initialize your own config file with:

`php artisan vendor:publish --provider="Scout\Solr\ScoutSolrServiceProvider"`

### scout:index

[](#scoutindex)

By default, Solr doesn't allow indexes (cores) to be created without providing the proper folders and files on the file system first. However, if a default config set is set up in the Solr instance this becomes possible through the API.
The `scout:index` command will only work if the Solr instance is properly configured and the config files has the corresponding name for the config set folder. For more information, see [https://solr.apache.org/guide/8\_9/config-sets.html#config-sets](https://solr.apache.org/guide/8_9/config-sets.html#config-sets)

To get the `_default` configset onto your server try the following (adjusting the command to match your solr version/location:

```
sudo cp -r /opt/solr-9.2.1/server/solr/configsets /var/solr/data
sudo chown -R solr:solr /var/solr/data/configsets
```

then checking that folder you should see something like:

```
sudo ls -lah /var/solr/data/configsets/

total 16K
drwxr-xr-x  4 solr solr 4.0K Jul 13 07:03 .
drwxr-x--- 13 solr solr 4.0K Jul 13 07:03 ..
drwxr-xr-x  3 solr solr 4.0K Jul 13 07:03 _default
drwxr-xr-x  3 solr solr 4.0K Jul 13 07:03 sample_techproducts_configs
```

most likely you can safely delete the `sample_techproducts_configs` folder from there unless you are using it :-)

### Cores (indexes)

[](#cores-indexes)

Within the config file a core (index) is not provided. The engine will determine which core to connect to using the `searchableAs()` method on the model.

Alternatively, if a specific model is on a different Solr instance, another configuration can be provided for this model. It's important for the configuration key to match the `searchableAs()` of the model.

When in Cloud mode i could not get this to work fully, so instead you could try:

#### Step 1: Create a collection in solr via admin panel.

[](#step-1-create-a-collection-in-solr-via-admin-panel)

```
http://127.0.0.1:8983/solr/#/~collections
```

choose add collection and configure it across your shards and replicas ( for demo mode use shards: 2 and replicas: 2)

#### Step 2: Setup your schema in the Model

[](#step-2-setup-your-schema-in-the-model)

make sure your model is configured to use the correct Searchable trait

```
